深 圳 大 学 实 验 报 告 课程名称: J a v a 实验序号: 上机实践 1 1 实验1 实验名称: 扫雷小游戏 班 级: 计算机 3 姓 名: 卢志敏 同 组 人: 实验日期: 2 0 0 8 年 1 2 月 2 0 日 教师签字: 一、实验目的 本实验的目的是让学生掌握LinkedList 类的常用方法。 二、实验环境 JDK1.5 Winxp 三、实验步骤与方法 编写一个Block 类,Block 对象具有String 类型和boolean 类型的成员变量,Block 对象可以使用setName(string)方法、getName()方法、isMine()、setIsMine(boolean)方法来设置对象的名字、返回该对象的名字,返回对象的boolean 类型的成员变量的值,设置对象的boolean 类型成员的值。 编写一个LayMines 类,该类提供 Public void layMinesForBlock(Block block[][],int mineCount) 方法,该方法可以将参数block 指定的二维数组中的mineCount 个单元随机设置为“雷”。 编写一个BlockView 类,该类的实例为Block 对象提供视图。 编写MineFrame 窗体类,该类将Block 类的实例和BlockView 类的实例做为成员,并负责二者之间的交互。 四、结果与分析 源代码: Block.java public class Block { String name;//数字 int number;//雷数 boolean boo=false;//是否为雷 /** Creates a new instance of Block */ public void setName(String name){ this.name=name; } public String getName(){ return name; } public void setNumber(int n){ number=n; } public int getNumber(){ return number; } boolean getIsMine(){ return boo; } public void setIsMine(boolean boo){ this.boo=boo; } } BlockView.java import java.awt.CardLayout; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.border.*; public class BlockView extends JPanel{ JLabel blockName; JButton blockCover; CardLayout card; /** Creates a new instance of BlockView */ public BlockView() { card=new CardLayout(); setLayout(card); blockName=new JLabel(); blockCover=new JButton(); blockName.setBorder(new TitledBorder(new EtchedBorder(),"")); add(blockCover,"cover"); add(blockName,"name"); } p...