square.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 32 行

JAVA
32
字号
import dslib.base.PairUos;

/**	A square with a size and position. */
public class Square extends Shape
{
	/**	Size of the square */
	protected int size;

	/**	Create a Square with size newSize , and positioned at (0,0)
		Analysis: Time = O(1) */
	public Square(int newSize)
	{
		size = newSize;
		x = 0;
		y = 0;
	}

	/**	Set the size to newSize 
		Analysis: Time = O(1) */
	public void setSize(int newSize)
	{
		size = newSize;
	}

	/**	String representation of the square 
		Analysis: Time = O(1) */
	public String toString()
	{
		return "\n" + indent + "Square with size " + size + "\n" + super.toString();
	}
}

⌨️ 快捷键说明

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