




已阅读5页,还剩24页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
课程设计(论文)题 目 名 称 记忆测试系统 课 程 名 称 专业课程设计 学 生 姓 名 学 号 系 、专 业 信息工程系、计算机科学与技术 指 导 教 师 2013年 11 月 2 日目 录1 前言12 需求分析12.1 任务和要求12.2 运行环境22.3 开发工具23 分析和设计23.1 系统分析及设计思路23.2 主要类图33.3 函数流程图44 具体代码实现65 课程设计总结215.1 程序运行结果或预期运行结果215.2 设计结论25参考文献26致 谢261前言伴随着社会科学技术的飞速发展,信息化时代也以闪电般的速度呈现在我们的面前,所以,计算机的发展更以其惊人的速度在发展着,生活中有许多复杂的问题都需要用计算机去解决,从而产生了新的思想,Java语言就是一种伴随着社会息技术的飞速发展而发展起来的强有力的计算机编程语言,它能够透彻地反映人们的思想,巧妙而充分地使计算机本身特性发挥到极致,便于编程人员根据社会的需要,灵活地编制出高级语言程序来实现生活和工作中的各种复杂程序。在当今众多的计算机程序设计语言中,面向对象技术正逐步替代传统的面向过程的程序设计技术,成为目前软件的主流开发方向,Java语言以它独到的面向对象特性在各类编程语言中脱颖而出,Java语言的快速发展与广泛应用有目共睹。Java语言是计算机能提供的最快而又最有效的语言,也是能够利用计算机所有硬件特性的编程语言。在当今信息高速发展的社会,Java语言越来越实用,可以通过Java实现更高更快的应用需求,Java语言将成为应用程序的开发和建设的核心技术,它能够有效地提高计算机性能和应用场合,满足各种用户的应用需求。 本论文主要介绍了记忆测试系统的相关使用方法,以及程序中应用到的相关技术和方法。本论文包括需求分析、系统功能介绍和系统功能实现三个主要部分。2 需求分析2.1任务和要求通过专业课程设计,还有根据团队合作的内容,我们做了相应的自主练习,笑话了课堂所解的内容,通过调试典型例题或习题积累调试JAVA程序的经验。逐渐培养了我们的编程能力,并且有助于培养学生综合运用数据库相关知识解决实际问题的能力。本设计要求对实际问题进行需求分析,提炼实际问题中的数据,建立关系模型,并在大型数据库中得以实现。同时要求对数据库的运营、管理及使用上进行必要的规划和实现。(1)根据需求,建立ER模型。通过ER图表示。(2)预计每个表的大致容量和增长速度。指定备份的方案,写出相关的备份命令。(3)从安全的角度出发,规划系统的角色、用户、权限,并通过相关的SQL实现。(4)从数据更新或修改的角度出发,设计至少1个存储过程。(5)以上所有命令及脚本均需测试,在设计报告中说明其功能并记录其输出。(6)针对常用的业务,创建包,同时实现一个函数放入包中。(7)从实际查询应用出发,为一些主要的应用模块设计至少3个参数化视图。(8)在此基础上,设计物理表结构,编写创建数据库表的语句。较高要求为在设计创建数据表语句的同时考虑性能上的要求,采用相关的磁盘存储技术。 (9)从数据检验的角度出发,为相关的表建立至少1个触发器2.2运行环境(1)WINDOWS2000/XP系统(2)editplus 或eclipse2.3开发工具JAVA3分析和设计3.1系统分析及设计思路记忆测试系统界面分级功能存储功能换图功能计时功能结束MemoryGameStringFileMemoryTestAreaShoeRecordDialogFileTreeSetArrayListStringRecordTimerFileThread选择级别后,将显示相应级别的测试区域。测试区域由若干个方块组成,每个方块都有一个图标,但该图标默认情况下不可见。用鼠标单击测试区中的任何一个方块,则计时器开始启动,同时该方块上的图标将显示出来。对于初级级别,用户必须用鼠标连续单击出6个图标相同的方块,也就是说,如果用户已经用鼠标连续单击出n(n6)个图标相同的方块,单击另一个房块时,如果该方块的图标和上一个相同,那么该方块的图标和前n 次单击出的方块的图标仍然可见,否则,前n次单击出的方块的图标都变为不可见。连续单击出该级别所要求的若干个图彪相同的方块后,将显示保存成绩对话框,成绩按所用时间排序。用户可以通过该对话框选择是否将自己的成绩保存到成绩表中。3.2主要类图MemoryGameactionPerformed()main() Block 类getOpenStateIcon()setOpenStateIcon()Record类setGradeFile()setTime()actionPerformed() ShowRecordDialog 类setGradeFile()showRecord()actionPerformed()ShowRecord类 setGradeFile()showRecord()actionPerformed()MemoryTestArea类initBlock()setImageName()actionPerformed()run()People类getTime()getName()compareTo()3.3函数流程图4具体代码实现/主类MemoryGameimport javax.swing.*;import java.awt.*;import java.awt.event.*;import java.io.*;import java.util.LinkedList;public class MemoryGame extends JFrame implements ActionListener JMenuBar bar; JMenu menuGrade,menuResult,menuIcon; JMenuItem oneGradeItem,twoGradeItem,threeGradeItem; JMenuItem oneGradeResult,twoGradeResult,threeGradeResult; JMenuItem carImageIcon,animalImageIcon; File fileOneGrade,fileTwoGrade,fileThreeGrade,gradeFile; String imageName; MemoryTestArea memoryArea; ShowRecordDialog showDiolag=null; int m=5,n=6; final int imageNumber=7; MemoryGame() fileOneGrade=new File(初级记忆排行榜.txt); fileTwoGrade=new File(中级记忆排行榜.txt); fileThreeGrade=new File(高级记忆排行榜.txt); bar=new JMenuBar(); menuGrade=new JMenu(选择级别); oneGradeItem=new JMenuItem(初级); twoGradeItem=new JMenuItem(中级); threeGradeItem=new JMenuItem(高级); menuGrade.add(oneGradeItem); menuGrade.add(twoGradeItem); menuGrade.add(threeGradeItem); menuResult=new JMenu(查看排行榜); oneGradeResult=new JMenuItem(初级排行榜); twoGradeResult=new JMenuItem(中级排行榜); threeGradeResult=new JMenuItem(高级排行榜); menuResult.add(oneGradeResult); menuResult.add(twoGradeResult); menuResult.add(threeGradeResult); menuIcon=new JMenu(选择图标); carImageIcon=new JMenuItem(汽车图标); animalImageIcon=new JMenuItem(动物图标); animalImageIcon.addActionListener(this); carImageIcon.addActionListener(this); menuIcon.add(carImageIcon); menuIcon.add(animalImageIcon); bar.add(menuGrade); bar.add(menuResult); bar.add(menuIcon); setJMenuBar(bar); oneGradeItem.addActionListener(this); twoGradeItem.addActionListener(this); threeGradeItem.addActionListener(this); oneGradeResult.addActionListener(this); twoGradeResult.addActionListener(this); threeGradeResult.addActionListener(this); if(!fileOneGrade.exists() try fileOneGrade.createNewFile(); catch(IOException exp) if(!fileTwoGrade.exists() try fileTwoGrade.createNewFile(); catch(IOException exp) if(!fileThreeGrade.exists() try fileThreeGrade.createNewFile(); catch(IOException exp) setBounds(100,100,400,360); setVisible(true); memoryArea=new MemoryTestArea(); imageName=new StringimageNumber; for(int i=0;iimageName.length;i+) imageNamei=new String(car+i+.jpg); m=5; n=6; gradeFile=fileOneGrade; memoryArea.initBlock(m,n,imageName,gradeFile); add(memoryArea,BorderLayout.CENTER); showDiolag=new ShowRecordDialog(); validate(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); public void actionPerformed(ActionEvent event) if(event.getSource()=oneGradeItem) m=5; n=6; gradeFile=fileOneGrade; memoryArea.initBlock(m,n,imageName,gradeFile); if(event.getSource()=twoGradeItem) m=6; n=7; gradeFile=fileTwoGrade; memoryArea.initBlock(m,n,imageName,gradeFile); if(event.getSource()=threeGradeItem) m=7; n=8; gradeFile=fileThreeGrade; memoryArea.initBlock(m,n,imageName,gradeFile); if(event.getSource()=carImageIcon) for(int i=0;iimageName.length;i+) imageNamei=new String(car+i+.jpg); memoryArea.setImageName(imageName); memoryArea.initBlock(m,n,imageName,gradeFile); if(event.getSource()=animalImageIcon) for(int i=0;iimageName.length;i+) imageNamei=new String(ani+i+.jpg); memoryArea.setImageName(imageName); memoryArea.initBlock(m,n,imageName,gradeFile); if(event.getSource()=oneGradeResult) showDiolag.setGradeFile(fileOneGrade); showDiolag.showRecord(); showDiolag.setVisible(true); if(event.getSource()=twoGradeResult) showDiolag.setGradeFile(fileTwoGrade); showDiolag.showRecord(); showDiolag.setVisible(true); if(event.getSource()=threeGradeResult) showDiolag.setGradeFile(fileThreeGrade); showDiolag.showRecord(); showDiolag.setVisible(true); public static void main(String args) new MemoryGame(); /MemoryTestArea类import javax.swing.*; import java.awt.event.*;import java.awt.*;import java.util.*;import java.io.*;public class MemoryTestArea extends JPanel implements ActionListener,Runnable int row,col; File gradeFile; ArrayList allBlockList; String imageFileName; LinkedList openIconList; LinkedList openBlockList; int success=0; Thread hintThead; JButton hintButton; int usedTime=0; JTextField showUsedTime,hintMessage; javax.swing.Timer timer; Record record; JPanel center,south; MemoryTestArea() setLayout(new BorderLayout(); allBlockList=new ArrayList(); openIconList=new LinkedList(); openBlockList=new LinkedList(); hintThead=new Thread(this); hintMessage=new JTextField(); hintMessage.setHorizontalAlignment(JTextField.CENTER); hintMessage.setEditable(false); hintMessage.setFont(new Font(宋体,Font.BOLD,18); center=new JPanel(); south=new JPanel(); hintButton=new JButton(提示); hintButton.addActionListener(this); showUsedTime=new JTextField(8); showUsedTime.setEditable(false); showUsedTime.setHorizontalAlignment(JTextField.CENTER); south.add(new JLabel(用时:) ; south.add(showUsedTime); south.add(new JLabel(提示图标位置(导致用时增加):) ; south.add(hintButton); add(south,BorderLayout.SOUTH); add(hintMessage,BorderLayout.NORTH); timer=new javax.swing.Timer(1000,this); record=new Record(); public void initBlock(int m,int n,String name,File f) row=m; col=n; gradeFile=f; center.removeAll(); imageFileName=name; ImageIcon icon=new ImageIconimageFileName.length; for(int i=0;iicon.length;i+) iconi=new ImageIcon(imageFileNamei); if(allBlockList.isEmpty() for(int i=0;irow*col;i+) allBlockList.add(new Block(); else allBlockList.clear(); for(int i=0;irow*col;i+) allBlockList.add(new Block(); for(int i=0;iallBlockList.size();i+) allBlockList.get(i).addActionListener(this); allBlockList.get(i).setOpenStateIcon(iconi%row); Collections.shuffle(allBlockList); center.setLayout(new GridLayout(row,col); for(int i=0;iallBlockList.size();i+) center.add(allBlockList.get(i); add(center,BorderLayout.CENTER); if(timer.isRunning() timer.stop(); hintMessage.setText(您需要用鼠标单击出+col+个同样图标的方块); usedTime=0; showUsedTime.setText(null); validate(); public void setImageName(String name) imageFileName=name; public void actionPerformed(ActionEvent e) if(e.getSource() instanceof Block) if(!timer.isRunning() timer.start(); Block block=(Block)e.getSource(); ImageIcon openStateIcon=block.getOpenStateIcon(); block.setIcon(openStateIcon); if(openIconList.size()=0) openIconList.add(openStateIcon); openBlockList.add(block); success=1; else ImageIcon temp=openIconList.getLast(); if(temp=openStateIcon&!(openBlockList.contains(block) success=success+1; openIconList.add(openStateIcon); openBlockList.add(block); if(success=col) for(int i=0;iallBlockList.size();i+) allBlockList.get(i).setEnabled(false); for(int j=0;jopenBlockList.size();j+) Block b=openBlockList.get(j); b.setDisabledIcon(b.getOpenStateIcon(); timer.stop(); record.setTime(usedTime); record.setGradeFile(gradeFile); record.setVisible(true); else if(temp!=openStateIcon)&(!(openBlockList.contains(block) openIconList.clear(); openBlockList.clear(); openIconList.add(openStateIcon); openBlockList.add(block); success=1; for(int i=0;iallBlockList.size();i+) if(allBlockList.get(i)!=block) allBlockList.get(i).setIcon(null); if(e.getSource()=hintButton) if(!hintThead.isAlive() hintThead=new Thread(this); for(int i=0;iallBlockList.size();i+) allBlockList.get(i).removeActionListener(this); usedTime=usedTime+10; try hintThead.start(); catch(IllegalThreadStateException ex) if(e.getSource()=timer) usedTime+; showUsedTime.setText(您的用时:+usedTime+秒); public void run() for(int i=0;iallBlockList.size();i+) allBlockList.get(i).setIcon(allBlockList.get(i).getOpenStateIcon(); try Thread.sleep(1200); catch(InterruptedException exp) for(int i=0;iallBlockList.size();i+) allBlockList.get(i).addActionListener(this); for(int i=0;iallBlockList.size();i+) if(!openBlockList.contains(allBlockList.get(i) allBlockList.get(i).setIcon(null); /Block 类import javax.swing.*;import java.awt.event.*;public class Block extends JButton ImageIcon openStateIcon; public ImageIcon getOpenStateIcon() return openStateIcon; public void setOpenStateIcon(ImageIcon icon) openStateIcon=icon; /Record类import java.io.*;import java.util.*;import javax.swing.*;import java.awt.event.*;import java.awt.*;public class Record extends JDialog implements ActionListener int time=0; JTextField yourName; JLabel label; JButton enter,cancel; File gradeFile=null; public Record() setBounds(100,100,330,160); setResizable(false); setModal(true); setVisible(false); enter=new JButton(确定); cancel=new JButton(取消); yourName=new JTextField(8); yourName.setText(匿名); enter.addActionListener(this); cancel.addActionListener(this); setLayout(new GridLayout(2,1); label=new JLabel(); add(label); JPanel p=new JPanel(); p.add(yourName); p.add(enter); p.add(cancel); add(p); public void setGradeFile(File f) gradeFile=f; setTitle(保存成绩到+gradeFile.getName(); label.setText(保存成绩到+gradeFile.getName(); validate(); public void setTime(int time) this.time=time; public void actionPerformed(ActionEvent e) if(e.getSource()=enter) LinkedList list=new LinkedList(); try RandomAccessFile out=new RandomAccessFile(gradeFile,rw); out.seek(out.length(); out.writeUTF(yourName.getText(); out.writeInt(time); out.close(); catch(Exception event) setVisible(false); if(e.getSource()=cancel) setVisible(false); /ShowRecordDialog 类import java.io.*;import java.util.*;import javax.swing.*;import java.awt.event.*;import java.awt.*;public class ShowRecordDialog extends JDialog implements ActionListener File gradeFile; JButton clear; JTextArea showArea=null; TreeSet treeSet; public ShowRecordDialog() treeSet=new TreeSet(); showArea=new JTextArea(6,4); showArea.setFont(new Font(楷体,Font.BOLD,20); clear=new JButton(清空排行榜); clear.addActionListener(this); add(new JScrollPane(showArea),BorderLayout.CENTER); add(clear,BorderLayout.SOUTH); setBounds(100,100,320,185); setModal(true); addWindowListener(new WindowAdapter() public void windwoClosing(WindowEvent e) setVisible(false); ); public void setGradeFile(File f) gradeFile=f; setTitle(f.getName(); public void showRecord() showArea.setText(null); treeSet.clear(); try RandomAccessFile in=new RandomAccessFile(gradeFile,rw); long fileLength=in.length(); long readPosition=0; while(readPositionfileLength) String name=in.readUTF(); int time=in.readInt(); readPosition=in.getFilePointer(); People people=new People(name,time); treeSet.add(people); in.close(); Iterator iter=treeSet.iterator(); while(iter.hasNext() People p=iter.next(); showArea.append(姓名:+p.getName()+,成绩: +p.getTime()+秒); showArea.append(n); catch(IOException exp)System.out.println(exp); public void actionPerformed(ActionEvent e) if(e.getSource()=clear) try File f=gradeFile.getAbsoluteFile(); gradeFile.delete(); f.createNewFile(); showArea.setText(排行榜被清空); catch(Exception ee) /ShowRecord类import java.io.*;import java.util.*;import javax.swing.*;import java.awt.event.*;import java.awt.*;public cl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025道路运输安全员考试题库及答案概
- 金融系本科毕业论文模板
- 眩晕,消化道出血,危重患者气道管理相关知识试题N0–N2(附答案)
- 粮食储备库存管理与调配流程
- 毕业论文要实证分析吗
- 项目班子配备情况
- 大理石产品定制化生产方案
- 排水管道建设质量控制与监测方案
- 临床医学概要外科复习试题及答案
- 商科专业毕业论文改革
- 员工自付社保协议书
- 网络直播带货对大学生消费观的影响机制研究
- cvte2107校招笔试题目及答案
- 活鹅宰杀协议书
- AI技术提升医学人才培养质量的探索与实践
- 美宜佳转让协议合同
- 混改公司合同协议模板
- 儿童多种维生素课件
- GA/T 2159-2024法庭科学资金数据清洗规程
- 江苏常州2025年公开招聘农村(村务)工作者笔试题带答案分析
- 2025年职工职业技能竞赛(物业管理师)参考试题(附答案)
评论
0/150
提交评论