⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sortingshapes.java

📁 Java程序设计技巧与开发实例附书源代码。
💻 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 + -