rect.java

来自「this sourse code for the hw problems in 」· Java 代码 · 共 29 行

JAVA
29
字号
class Rect extends GeoFigure {
     // Data Fields
	protected double width;     // input - essential attribute
	protected double length;    // input - essential attribute 
	
     // Methods
	// Constructors
	public Rect()
	{this(0, 0);}
	
	public Rect(double w, double l)
	{width = w; length = l;}
	// Modifiers
	public void setWidth(double w) { width = w;}
	public void setLength(double l) { length = l;}
		
	// Accessors:
	final public double getWidth() { return width;}
	final public double getLength() { return length;}
	
	public double computeArea() { return length * width;}
	
	public double computePerimeter() {return 2 * (length + width);}
		public String toString()
	{ return "Rectangle:" + length + ", " + width; }

 } // class Rect

⌨️ 快捷键说明

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