java1到100随机排序_利用随机函数产生10个1~100之间的整数,按从小到大的顺序排列输出...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

public interface planeGraphics2

{

public abstract double area();

public abstract double perimeter();

public abstract void print();

}

public class rectangle2 implements planeGraphics2

{

protected double length;

protected double width;

public rectangle2(double length,double width)

{ this.length=length;

this.width=width;

}

public rectangle2(double width)

{

this.length=width;

this.width=width;

}

public rectangle2(0

{

this(0,0);

}

public rectangle2(rectangle2 r1)

{ this(r1.length,r1.width);

}

public double area()

{

return this.width*this.length;

}

public double perimeter()

{

return(this.width+this.length)*2;

}

public void print()

{

if (this.length==this.width)

system.out.println("一个矩形。边长为"+this.length);

else

system.out.print("一个长方形,长度为"+this.length+",宽度"+this.width);

system.out.println(",面积为"+this.area()+",周长为"+this.perimeter());

}

public static void main(string args[])

{

rectangle2 r1= new rectangle2(10,20);

r1.print();

r1=new rectangle2(10);

r1.print();

}

}


版权声明:本文为weixin_42470196原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。