JAVA10

package 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();
    }
}

  

posted @ 2020-04-18 20:00  一只小阿giao  阅读(144)  评论(0编辑  收藏  举报