rectangle.java

来自「主要是java书上的一些代码」· Java 代码 · 共 36 行

JAVA
36
字号
//: Rectangle.java

//package g3ds.joop.ch5;

public class Rectangle{
	//矩形的长和宽
	private double width;
	private double height;
	
	public Rectangle(double w, double h){
		width=w;
		height=h;
	}
	
	//计算矩形的面积	
	public double area(){
		return width*height;
	}
	
	//设置矩形边长值
	public void setWidth(double w){
		width=w;
	}
	
	public void setHeight(double h){
		height=h;
	}
		
	public double getWidth(){
		return width;
	}
	
	public double getHeight(){
		return height;
	}
}

⌨️ 快捷键说明

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