刚才没有提供Box类
下面是Box类的代码:import java.awt.*;
public class Box implements Cloneable
{
private boolean isColored = true;
//indicates whether to show the box by the background of canvas
private Dimension dimension = new Dimension();
//include the width and height of box
/**
* construct a new Box by the default width and height which are specified in RussanSqaure
* @param isColored boolean. true indicates to show this box by the background of canvas
* */
public Box(boolean isColored)
{
this.isColored = isColored;
}
/**
* construct a new Box with the spcified isColored and width, height
* @param isColored boolean. true indicates to show this box by the background of canvas
* @param width int. spcify the width of each box
* @param height int. spcify the height of each box
* */
public Box(boolean isColored, int width, int height)
{
this.isColored = isColored;
this.dimension = new Dimension(width, height);
}
/**
* to detect whether this box is shown by the background of canvas
* @return true indicates this box will be shown by the background of canvas
* */
public boolean isColored()
{
return isColored;
}
/**
* to decide whether to set the color of box as the background of canvas or not
* @param isColored boolean. true to set the color of box as the background of canvas
* */
public void setColor(boolean isColored)
{
this.isColored = isColored;
}
/**
* to get the dimesion of box
* @param dimension of box
* */
public Dimension getDimension()
{
return this.dimension;
}
/**
* to custome the clone()method
* @param box Object
* */
public Object clone()
{
Object clonedBox = null;
try
{
clonedBox = super.clone();
}
catch(CloneNotSupportedException e)
{
}
return clonedBox;
} public static void main(String[] args) {
}
}
下面是Box类的代码:import java.awt.*;
public class Box implements Cloneable
{
private boolean isColored = true;
//indicates whether to show the box by the background of canvas
private Dimension dimension = new Dimension();
//include the width and height of box
/**
* construct a new Box by the default width and height which are specified in RussanSqaure
* @param isColored boolean. true indicates to show this box by the background of canvas
* */
public Box(boolean isColored)
{
this.isColored = isColored;
}
/**
* construct a new Box with the spcified isColored and width, height
* @param isColored boolean. true indicates to show this box by the background of canvas
* @param width int. spcify the width of each box
* @param height int. spcify the height of each box
* */
public Box(boolean isColored, int width, int height)
{
this.isColored = isColored;
this.dimension = new Dimension(width, height);
}
/**
* to detect whether this box is shown by the background of canvas
* @return true indicates this box will be shown by the background of canvas
* */
public boolean isColored()
{
return isColored;
}
/**
* to decide whether to set the color of box as the background of canvas or not
* @param isColored boolean. true to set the color of box as the background of canvas
* */
public void setColor(boolean isColored)
{
this.isColored = isColored;
}
/**
* to get the dimesion of box
* @param dimension of box
* */
public Dimension getDimension()
{
return this.dimension;
}
/**
* to custome the clone()method
* @param box Object
* */
public Object clone()
{
Object clonedBox = null;
try
{
clonedBox = super.clone();
}
catch(CloneNotSupportedException e)
{
}
return clonedBox;
} public static void main(String[] args) {
}
}
这个地方计算错误。i,j互换位置。