求java汉诺塔源代码的注解(急!)

来源:百度知道 编辑:UC知道 时间:2024/05/26 01:11:10
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 盘子;
}

import java.awt.*;
public class TowerPoint //公共类TowerPoint
{
int x,y; //定义2个int类型的变量
boolean 有盘子; //定义一个boolean类型的变量
Disk 盘子=null; //初始化一个对象"盘子"并赋值为空
HannoiTower con=null; //初始化一个HannoiTower类的对象"con"并赋值为空

public TowerPoint(int x,int y,boolean boo) //构造函数,有3个参数,x,y,boo
{
this.x=x; //将参数赋给当前x
this.y=y; //将参数赋给当前y

有盘子=boo; //将boo赋给"有盘子"
}
public boolean 是否有盘子() //定义一个返回boolean类型的方法"是否有盘子"
{
return 有盘子; //返回boolean类型的"有盘子"
}
public void set有盘子(boolean boo) //set方法,并且参数为boolean
{
有盘子=boo; //将boo赋给有盘子
}

public int getX() //取得x方法
{
return x; //返回x
}
public int getY()//取得y方法
{
return y; //返回y
}
public void 放置盘子(Disk 盘子,HannoiTower con) //定义一个有2个参数的"放置盘子"方法。参数是Disk类和HannoiTower类
{
this.con=con; //当前con等于参数con
con.setLayout(null); //调用on对象的方法set