1   // joi/5/bank/class Month                         
2   //                                                            
3   //                                                            
4   // Copyright 2003 Bill Campbell and Ethan Bolker                         
5                                                               
6   import java.io.*;
7   import java.util.Calendar;
8   
9   /**
10   * The Month class implements an object that keeps
11   * track of the month of the year. 
12   *
13   * @version 5
14   */ 
15  
16  public class Month 
17  {
18      private static final String[] monthName =
19          {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
20           "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
21  
22      private int month;
23      private int year;
24  
25      /**
26       *  Month constructor constructs a Month object
27       *  initialized to the current month and year.
28       */
29  
30      public Month()
31      {
32          Calendar rightNow = Calendar.getInstance();
33          month = rightNow.get( Calendar.MONTH );
34          year  = rightNow.get( Calendar.YEAR );
35      }
36  
37      /**
38       *  Advance to next month.
39       */
40  
41      public void next() 
42      {
43          // needs completion
44      }
45  
46      /**
47       * How a Month is displayed as a String -
48       * for example, "Jan, 2003".
49       * 
50       * @return String representation of the month.
51       */
52  
53  //     public String toString() 
54  //     {
55  //     }                                                           
56  
57      /**
58       * For unit testing.
59       */
60  
61      public static void main( String[] args ) 
62      {
63          Month m = new Month();
64          for (int i=0; i < 14; i++, m.next()) {
65              System.out.println(m);
66          }
67          for (int i=0; i < 35; i++, m.next()); // no loop body
68          System.out.println("three years later: " + m);
69          for (int i=0; i < 120; i++, m.next());// no loop body
70          System.out.println("ten years later: " + m);
71      }
72  }
73