📄 block.java
字号:
package diamonds3;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Block {
int x,y; //方块的位置
int color; //方块的颜色
public Block() {
this.x = 0;
this.y = 0;
this.color = 0;
}
public Block(int x,int y,int c) {
this.x=x; this.y=y; this.color=c;
}
public void setBlock(int x, int y, int c) {
//System.out.println(x+y);
this.x = x;
this.y = y;
this.color = c;
}
public void setBlock(Block b) {
this.x=b.x;
this.y=b.y;
this.color=b.color;
}
public boolean equals(Block obj) {
//重写该方法,判断方块是否相同
return x==obj.x && y==obj.y && color==obj.color;
}
public boolean isInRange(Panel pnl) {
//自定义方法,判断方块是否在有效范围内 80<= x <=240 20<=y<240
//System.out.println(x+y);
return x>=80 && x<=240 && y>=20 && y<=240;
}
public int getI(Panel pnl){return (x-80)/20;}
public int getJ(Panel pnl){return (y+40)/20;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -