public class chuanglei {// 创建一个Rectangle类
double width, length;//
double area, zhou;
chuanglei(double x) {
width = x;
length = x;
}
chuanglei(double w, double len) {
width = w;
length = len;
}
public double zhouRectangle() {
zhou = (width + length) * 2;
return zhou;
}
public double areaRectangle() {
area = width * length;
return area;
}
public static void main(String[] args) {
double c, s;
chuanglei Rectangle1 = new chuanglei(15, 23);
chuanglei Rectangle2 = new chuanglei(6);
c = Rectangle1.zhouRectangle();
s = Rectangle2.areaRectangle();
System.out.println("周长是:" + c);
System.out.println("面积是:" + s);
}
}
double width, length;//
double area, zhou;
chuanglei(double x) {
width = x;
length = x;
}
chuanglei(double w, double len) {
width = w;
length = len;
}
public double zhouRectangle() {
zhou = (width + length) * 2;
return zhou;
}
public double areaRectangle() {
area = width * length;
return area;
}
public static void main(String[] args) {
double c, s;
chuanglei Rectangle1 = new chuanglei(15, 23);
chuanglei Rectangle2 = new chuanglei(6);
c = Rectangle1.zhouRectangle();
s = Rectangle2.areaRectangle();
System.out.println("周长是:" + c);
System.out.println("面积是:" + s);
}
}