JAVA这个题怎么做呀,可以看看嘛~

创建Rectangle类和对象:

1)创建一个Rectangle类;

2)属性: width 和height ,double型成员变量,需要对其进行封装3)不带参数的构造方法,width 和height给初始值3, 5

4)方法:计算并输出长方形的周长calculength0

5)编写测试类,创建一个Rectangle的对象, 调用周长的方法

public class Rectangle{
    double width;
    double height;
    public Rectangle(){
        width=3;
        height=5;
    }
    public double calculength() {
        return 2*(width+height);
    }

    public static void main(String[] args) {
        Rectangle r=new Rectangle();
        System.out.println(r.calculength());
    }
}

img