4,17作业

public class Rectangle {
	int length;
	int width;

	public void getArea() {
		System.out.println(length * width);
	}

	public void getPer() {
		System.out.println(2 * length + 2 * width);
	}

	public void showAll() {
		System.out.println("长度为:" + length);
		System.out.println("宽度为:" + width);
		System.out.print("周长为:");
		getPer();
		System.out.print("面积为:");
		getArea();

	}
}

  

public class used {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Rectangle r1 = new Rectangle();
		r1.length = 30;

		r1.width = 40;

		r1.showAll();

	}

}

  

猜你喜欢

转载自www.cnblogs.com/Syz1107/p/12753342.html
今日推荐