towerpoint.java
来自「这是关于java编程的一本书书的源代码 一共有15章」· Java 代码 · 共 48 行
JAVA
48 行
import java.awt.*;
public class TowerPoint
{
int x,y;
boolean 有盘子;
Disk 盘子=null;
HannoiTower con=null;
public TowerPoint(int x,int y,boolean boo)
{
this.x=x;
this.y=y;
有盘子=boo;
}
public boolean 是否有盘子()
{
return 有盘子;
}
public void set有盘子(boolean boo)
{
有盘子=boo;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public void 放置盘子(Disk 盘子,HannoiTower con)
{
this.con=con;
con.setLayout(null);
this.盘子=盘子;
con.add(盘子);
int w=盘子.getBounds().width;
int h=盘子.getBounds().height;
盘子.setBounds(x-w/2,y-h/2,w,h);
有盘子=true;
con.validate();
}
public Disk 获取盘子()
{
return 盘子;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?