求助大侠帮忙标注注释(Java扫雷)
程序代码是找到了,小弟看不懂,帮忙大侠多教教小弟多标标注释,让小弟明白明白。importjavax.swing.ImageIcon;//程序入口publicclassBl...
程序代码是找到了,小弟看不懂,帮忙大侠多教教小弟多标标注释,让小弟明白明白。
import javax.swing.ImageIcon; //程序入口
public class Block {
String name; //名字,比如"雷"或数字
int aroundMineNumber; //周围雷的数目
ImageIcon mineIcon; //雷的图标
boolean isMine=false; //是否是雷
boolean isMark=false; //是否被标记
boolean isOpen=false; //是否被挖开
public void setName(String name) {
this.name=name;
}
public void setAroundMineNumber(int n) {
aroundMineNumber=n;
}
public int getAroundMineNumber() {
return aroundMineNumber;
}
public String getName() {
return name;
}
public boolean isMine() {
return isMine;
}
public void setIsMine(boolean b) {
isMine=b;
}
public void setMineIcon(ImageIcon icon){
mineIcon=icon;
}
public ImageIcon getMineicon(){
return mineIcon;
}
public boolean getIsOpen() {
return isOpen;
}
public void setIsOpen(boolean p) {
isOpen=p;
}
public boolean getIsMark() {
return isMark;
}
public void setIsMark(boolean m) {
isMark=m;
}
import javax.swing.*;
import java.awt.*;
public class BlockView extends JPanel{
JLabel blockNameOrIcon; //用来显示Block对象的name、number和mineIcon属性
JButton blockCover; //用来遮挡blockNameOrIcon.
CardLayout card; //卡片式布局
BlockView(){
card=new CardLayout();
setLayout(card);
blockNameOrIcon=new JLabel("",JLabel.CENTER);
blockNameOrIcon.setHorizontalTextPosition(AbstractButton.CENTER);
blockNameOrIcon.setVerticalTextPosition(AbstractButton.CENTER);
blockCover=new JButton();
add("cover",blockCover);
add("view",blockNameOrIcon);
}
public void giveView(Block block){
if(block.isMine){
blockNameOrIcon.setText(block.getName());
blockNameOrIcon.setIcon(block.getMineicon());
}
else {
int n=block.getAroundMineNumber();
if(n>=1)
blockNameOrIcon.setText(""+n);
else
blockNameOrIcon.setText(" ");
}
}
public void seeBlockNameOrIcon(){
card.show(this,"view");
validate();
}
public void seeBlockCover(){
card.show(this,"cover");
validate();
}
public JButton getBlockCover(){
return blockCover;
}
} 展开
import javax.swing.ImageIcon; //程序入口
public class Block {
String name; //名字,比如"雷"或数字
int aroundMineNumber; //周围雷的数目
ImageIcon mineIcon; //雷的图标
boolean isMine=false; //是否是雷
boolean isMark=false; //是否被标记
boolean isOpen=false; //是否被挖开
public void setName(String name) {
this.name=name;
}
public void setAroundMineNumber(int n) {
aroundMineNumber=n;
}
public int getAroundMineNumber() {
return aroundMineNumber;
}
public String getName() {
return name;
}
public boolean isMine() {
return isMine;
}
public void setIsMine(boolean b) {
isMine=b;
}
public void setMineIcon(ImageIcon icon){
mineIcon=icon;
}
public ImageIcon getMineicon(){
return mineIcon;
}
public boolean getIsOpen() {
return isOpen;
}
public void setIsOpen(boolean p) {
isOpen=p;
}
public boolean getIsMark() {
return isMark;
}
public void setIsMark(boolean m) {
isMark=m;
}
import javax.swing.*;
import java.awt.*;
public class BlockView extends JPanel{
JLabel blockNameOrIcon; //用来显示Block对象的name、number和mineIcon属性
JButton blockCover; //用来遮挡blockNameOrIcon.
CardLayout card; //卡片式布局
BlockView(){
card=new CardLayout();
setLayout(card);
blockNameOrIcon=new JLabel("",JLabel.CENTER);
blockNameOrIcon.setHorizontalTextPosition(AbstractButton.CENTER);
blockNameOrIcon.setVerticalTextPosition(AbstractButton.CENTER);
blockCover=new JButton();
add("cover",blockCover);
add("view",blockNameOrIcon);
}
public void giveView(Block block){
if(block.isMine){
blockNameOrIcon.setText(block.getName());
blockNameOrIcon.setIcon(block.getMineicon());
}
else {
int n=block.getAroundMineNumber();
if(n>=1)
blockNameOrIcon.setText(""+n);
else
blockNameOrIcon.setText(" ");
}
}
public void seeBlockNameOrIcon(){
card.show(this,"view");
validate();
}
public void seeBlockCover(){
card.show(this,"cover");
validate();
}
public JButton getBlockCover(){
return blockCover;
}
} 展开
1个回答
展开全部
import javax.swing.ImageIcon; //程序入口
public class Block {
String name; //名字,比如"雷"或数字
int aroundMineNumber; //周围雷的数目
ImageIcon mineIcon; //雷的图标
boolean isMine=false; //是否是雷
boolean isMark=false; //是否被标记
boolean isOpen=false; //是否被挖开
public void setName(String name) {
this.name=name;
}
//设置周围的雷数
public void setAroundMineNumber(int n) {
aroundMineNumber=n;
}
//获得周围的雷数
public int getAroundMineNumber() {
return aroundMineNumber;
}
public String getName() {
return name;
}
//判断是否是雷
public boolean isMine() {
return isMine;
}
//设置是否为雷
public void setIsMine(boolean b) {
isMine=b;
}
//设置雷的图标
public void setMineIcon(ImageIcon icon){
mineIcon=icon;
}
//获得雷的图标
public ImageIcon getMineicon(){
return mineIcon;
}
//确定雷是否被挖开
public boolean getIsOpen() {
return isOpen;
}
//设置为已经被挖开
public void setIsOpen(boolean p) {
isOpen=p;
}
//返回此处是否已经被标记
public boolean getIsMark() {
return isMark;
}
//设置此处是否已经被标记
public void setIsMark(boolean m) {
isMark=m;
}
import javax.swing.*;
import java.awt.*;
public class BlockView extends JPanel{
JLabel blockNameOrIcon; //用来显示Block对象的name、number和mineIcon属性
JButton blockCover; //用来遮挡blockNameOrIcon.
CardLayout card; //卡片式布局
BlockView(){
card=new CardLayout();
setLayout(card);
blockNameOrIcon=new JLabel("",JLabel.CENTER);
blockNameOrIcon.setHorizontalTextPosition(AbstractButton.CENTER);
blockNameOrIcon.setVerticalTextPosition(AbstractButton.CENTER);
blockCover=new JButton();
add("cover",blockCover);
add("view",blockNameOrIcon);
}
//给出视觉效果变化
public void giveView(Block block){
// 如果是雷,将对应的图标和文字更改
if(block.isMine){
blockNameOrIcon.setText(block.getName());
blockNameOrIcon.setIcon(block.getMineicon());
}
else {
int n=block.getAroundMineNumber();
if(n>=1)
blockNameOrIcon.setText(""+n);
else
blockNameOrIcon.setText(" ");
}
}
public void seeBlockNameOrIcon(){
card.show(this,"view");
validate();
}
public void seeBlockCover(){
card.show(this,"cover");
validate();
}
public JButton getBlockCover(){
return blockCover;
}
}
cover 和 view 你没有给出具体的程序,我就不知道是对应的什么了。希望对你有帮助
public class Block {
String name; //名字,比如"雷"或数字
int aroundMineNumber; //周围雷的数目
ImageIcon mineIcon; //雷的图标
boolean isMine=false; //是否是雷
boolean isMark=false; //是否被标记
boolean isOpen=false; //是否被挖开
public void setName(String name) {
this.name=name;
}
//设置周围的雷数
public void setAroundMineNumber(int n) {
aroundMineNumber=n;
}
//获得周围的雷数
public int getAroundMineNumber() {
return aroundMineNumber;
}
public String getName() {
return name;
}
//判断是否是雷
public boolean isMine() {
return isMine;
}
//设置是否为雷
public void setIsMine(boolean b) {
isMine=b;
}
//设置雷的图标
public void setMineIcon(ImageIcon icon){
mineIcon=icon;
}
//获得雷的图标
public ImageIcon getMineicon(){
return mineIcon;
}
//确定雷是否被挖开
public boolean getIsOpen() {
return isOpen;
}
//设置为已经被挖开
public void setIsOpen(boolean p) {
isOpen=p;
}
//返回此处是否已经被标记
public boolean getIsMark() {
return isMark;
}
//设置此处是否已经被标记
public void setIsMark(boolean m) {
isMark=m;
}
import javax.swing.*;
import java.awt.*;
public class BlockView extends JPanel{
JLabel blockNameOrIcon; //用来显示Block对象的name、number和mineIcon属性
JButton blockCover; //用来遮挡blockNameOrIcon.
CardLayout card; //卡片式布局
BlockView(){
card=new CardLayout();
setLayout(card);
blockNameOrIcon=new JLabel("",JLabel.CENTER);
blockNameOrIcon.setHorizontalTextPosition(AbstractButton.CENTER);
blockNameOrIcon.setVerticalTextPosition(AbstractButton.CENTER);
blockCover=new JButton();
add("cover",blockCover);
add("view",blockNameOrIcon);
}
//给出视觉效果变化
public void giveView(Block block){
// 如果是雷,将对应的图标和文字更改
if(block.isMine){
blockNameOrIcon.setText(block.getName());
blockNameOrIcon.setIcon(block.getMineicon());
}
else {
int n=block.getAroundMineNumber();
if(n>=1)
blockNameOrIcon.setText(""+n);
else
blockNameOrIcon.setText(" ");
}
}
public void seeBlockNameOrIcon(){
card.show(this,"view");
validate();
}
public void seeBlockCover(){
card.show(this,"cover");
validate();
}
public JButton getBlockCover(){
return blockCover;
}
}
cover 和 view 你没有给出具体的程序,我就不知道是对应的什么了。希望对你有帮助
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询