public class Arrays {
    public static final String[] MONTHS= {"January", "February", "March", "April",
                                  "May", "June", "July", "August",
                                  "September", "October", "November", "December"};
    public int field1;

    /** = name of month m (given 1 <= m <= 12; January is month 1) */
    public static String month(int m) {
        return MONTHS[m-1];
    }
    
   /** = name of month m (given 1 <= m <= 12; January is month 1) 
          It is an error if !(1 <= m <= 12), and the empty String is returned. */
    public static String monthName(int m) {
        if (m < 1 || m > 12)
            return "";
        return MONTHS[m-1];
    }
    
    // = b and c are equal --they have the same elements
    public static boolean equals(Object[] b, Object[] c) {
        if (b == null && c == null)
            return true;
        if (b == null || c == null)
            return false;
        if (b.length != c.length)
            return false;
        // inv: b[0..i-1] = c[0..i-1]
        for (int i= 0; i != b.length; i= i+1) {
            if (! b[i].equals(c[i])) {
                return false;
            }
        }
        return true;
        
    }
    
    // print out information about this instance
    public void classes() {
        Class cj= this.getClass();
        System.out.println(cj.getName());
        
        System.out.println("Here are the fields in this instance");
        
        Object[] fields= cj.getFields();
        System.out.println(getArray(fields));
        
        System.out.println();
        System.out.println("Here are the methods in this instance");
        Object[] methods= cj.getMethods();
        System.out.println(getArray(methods));
        
    }
    
    /** = a string containing a paren-delimited list of the elements of b,
          separated by \n. if null, the word null
          */
    public static String getArray(Object[] b) {
        if (b == null) {
            return "null";
        }
        
        String res= "(";
        // inv: b[0..i-1] has been added res
        for (int i= 0; i != b.length; i= i+1) {
            if (i != 0) {
                res= res + "\n";
            }
            res= res + b[i].toString();
        }
        
        return res + ")";
        
    }
    
    /** = an array containing the names of months in m1..m2, where 1<=m1<=m2<=12 */
    public static String[] subMonths(int m1, int m2) {
        String[] sub= new String[m2+1-m1];  // the array to return
        //inv: Months m1..m1+i-1 have been added to sub
        for (int i= 0; i != sub.length; i= i+1) {
            sub[i]= MONTHS[m1+i-1];
        }
        return sub;
    }
    
    

}