Пример #1
0
 public static void main(String[] args) {
   // Create an array of balloons
   Balloon[] thing = new Balloon[500];
   // build the first balloon
   thing[0] = new Balloon();
   System.out.println(thing[0]);
   // build the second balloon
   thing[Balloon.getQuantity()] = new Balloon(12, "white");
   // build the third balloon
   thing[Balloon.getQuantity()] = new Balloon(6, "yellow");
   // print the number of balloons made today
   System.out.printf("Number of balloons made = %d%n", Balloon.getQuantity());
   // Destruct the balloon
   Balloon.destruct(1, thing);
   // print the number of balloons remaining
   System.out.printf("Number of balloons made = %d%n", Balloon.getQuantity());
   // Show the Balloons' characteristics
   // each is the pointer
   for (Balloon each : thing) {
     // only shows the object if it is defined
     if (each != null) System.out.println(each);
   }
 }