第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > java从小到大排序函数_利用随机函数产生10个1~100之间的整数 按从小到大的顺序排列输出...

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

时间:2019-06-23 10:11:32

相关推荐

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

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

publicinterfaceplaneGraphics2

{

publicabstractdoublearea();

publicabstractdoubleperimeter();

publicabstractvoidprint();

}

publicclassrectangle2implementsplaneGraphics2

{

protecteddoublelength;

protecteddoublewidth;

publicrectangle2(doublelength,doublewidth)

{this.length=length;

this.width=width;

}

publicrectangle2(doublewidth)

{

this.length=width;

this.width=width;

}

publicrectangle2(0

{

this(0,0);

}

publicrectangle2(rectangle2r1)

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

}

publicdoublearea()

{

returnthis.width*this.length;

}

publicdoubleperimeter()

{

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

}

publicvoidprint()

{

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

}

publicstaticvoidmain(stringargs[])

{

rectangle2r1=newrectangle2(10,20);

r1.print();

r1=newrectangle2(10);

r1.print();

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。