JAVA10
2021-02-13 06:17
标签:main a10 矩形 owa out 面积 pre pac pack JAVA10 标签:main a10 矩形 owa out 面积 pre pac pack 原文地址:https://www.cnblogs.com/qwer45/p/12727732.htmlpackage work;
public class Rectangle {
int length;
int width;
public void showAll() {
System.out.println("矩形长为:" + length + "矩形宽为:" + width);
}
public void getArea() {
System.out.println("矩形面积为:" + length * width);
}
public void getPer() {
System.out.println("矩形周长为:" + (length + width) * 2);
}
}
package work;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Rectangle R=new Rectangle();
R.length=3;
R.width=2;
R.showAll();
R.getArea();
R.getPer();
}
}