⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 towerpoint.java

📁 JAVA写的图形化汉诺塔程序 swing实现
💻 JAVA
字号:
package chapter1;
public class TowerPoint
{
	int x,y;          //the coordinate of the tower point 
	boolean aDisk;    //whether there is a disk at the tower point 
	Disk disk  = null;
	HannoiTower con = null;// the container of the disk
	public TowerPoint (int x,int y,boolean b)
	{
		this.x = x;
		this.y = y;
		aDisk = b;
	}
	public boolean isADisk()
	{
		return aDisk;
	}
	public void setIsDisk(boolean b)
	{
		aDisk = b;
	}
	public int getX()
	{
		return x;
	}
	public int getY()
	{
		return y;
	}
	public void setDisk(Disk disk,HannoiTower con)
	{
		this.con = con;
		con.setLayout(null);
		this.disk = disk;
		con.add(disk);
		int w = disk.getBounds().width;
		int h = disk.getBounds().height;
		disk.setBounds(x-w/2,y-h/2,w,h);
		this.aDisk = true;
		con.validate();
	}
	public Disk getDisk()
	{
		return disk;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -