首页 > 其他 > 详细

2020-4-19

时间:2020-04-19 12:14:30      阅读:69      评论:0      收藏:0      [点我收藏+]
package hm_4_19;

public class Rectangle {
    public int length ;
    public int width;
    public Rectangle(int length, int width) {
        super();
        this.length = length;
        this.width = width;
    }
    public int getArea() {
        // 面积
        int area = length*width;
        return area;
    }
    public int getPer() {
        // 周长
        int per = (length+width)*2;
        return per;
    }
    public void showAll() {
        // 所有属性
        System.out.println("长"+length+"宽"+width+"面积"+getArea()+"周长"+getPer());

    }
    public static void main(String[] args) {
        Rectangle r = new Rectangle(20, 30);
        r.showAll();
    }
}

 

2020-4-19

原文:https://www.cnblogs.com/wzm7282/p/12730775.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!