📄 sortingshapes.java
字号:
public class SortingShapes
{
public static void showShapes(String title, Shape shapes[])
{
System.out.println(title);
for (int i = 0; i < shapes.length; i++)
{
System.out.println(shapes[i]);
}
}
public static void main(String args[])
{
Rectangle r[] =
{
new Rectangle(2, 6),
new Rectangle(3, 3), new Rectangle(1, 4)};
Circle c[] =
{
new Circle(3), new Circle(2), new Circle(1)};
for (int i = 0; i < r.length; i++)
{
r[i].computeArea();
r[i].computePerimeter();
c[i].computeArea();
c[i].computePerimeter();
}
showShapes("Unsorted Rectangles", r);
Sorter.sort(r);
showShapes("Sorted Rectangles", r);
showShapes("Unsorted Circles", c);
Sorter.sort(c);
showShapes("Sorted Circles", c);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -