欢迎来到天天文库
浏览记录
ID:38473869
大小:64.50 KB
页数:13页
时间:2019-06-13
《记忆测试系统-JAVA实现》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//主类MemoryGameimportjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.io.*;importjava.util.LinkedList;publicclassMemoryGameextendsJFrameimplementsActionListener{JMenuBarbar;JMenumenuGrade,menuResult,menuIcon;JMenuItemoneGradeItem,twoGradeItem,threeGra
2、deItem;JMenuItemoneGradeResult,twoGradeResult,threeGradeResult;JMenuItemcarImageIcon,animalImageIcon;FilefileOneGrade,fileTwoGrade,fileThreeGrade,gradeFile;StringimageName[];MemoryTestAreamemoryArea;ShowRecordDialogshowDiolag=null;intm=5,n=6;finalintimageNumber=7;Me
3、moryGame(){fileOneGrade=newFile("初级记忆排行榜.txt");fileTwoGrade=newFile("中级记忆排行榜.txt");fileThreeGrade=newFile("高级记忆排行榜.txt");bar=newJMenuBar();menuGrade=newJMenu("选择级别");oneGradeItem=newJMenuItem("初级");twoGradeItem=newJMenuItem("中级");threeGradeItem=newJMenuItem("高级");me
4、nuGrade.add(oneGradeItem);menuGrade.add(twoGradeItem);menuGrade.add(threeGradeItem);menuResult=newJMenu("查看排行榜");oneGradeResult=newJMenuItem("初级排行榜");twoGradeResult=newJMenuItem("中级排行榜");threeGradeResult=newJMenuItem("高级排行榜");menuResult.add(oneGradeResult);menuResul
5、t.add(twoGradeResult);menuResult.add(threeGradeResult);menuIcon=newJMenu("选择图标");carImageIcon=newJMenuItem("汽车图标");animalImageIcon=newJMenuItem("动物图标");animalImageIcon.addActionListener(this);carImageIcon.addActionListener(this);menuIcon.add(carImageIcon);menuIcon.a
6、dd(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.addAc
7、tionListener(this);threeGradeResult.addActionListener(this);if(!fileOneGrade.exists()){try{fileOneGrade.createNewFile();}catch(IOExceptionexp){}}if(!fileTwoGrade.exists()){try{fileTwoGrade.createNewFile();}catch(IOExceptionexp){}}if(!fileThreeGrade.exists()){try{fil
8、eThreeGrade.createNewFile();}catch(IOExceptionexp){}}setBounds(100,100,400,360);setVisible(true);memoryArea=newMemoryTestArea();imageName=
此文档下载收益归作者所有