/** TestGenerations test drives Person, Mother, Grandmother, and Aunt
 */
public class TestGenerationsSolution {
  public static void main(String[] args) {
    // declare some Persons
    Person p;
    Mother m;
    Grandmother g;
    Aunt a;

    m= new Mother("Alice", "Margaret, Eleanor, Susan");
    // OUR EXAMPLE COMMENTS
    // A new instance of class Mother created
    // Mother(String n, String dL) (rule 1)
    // Person(String n) (rule 6)
    // instance variable name refers to "Alice"
    // instance variable daughterList refers to
    // "Margaret, Eleanor, Susan"
    // Assignment allowed: both side of type Mother (rule 2)

    p= new Person("Alice");
    // YOUR COMMENTS HERE
    // A new instance of class Person created
    // Person(String n) (rule 1)
    // instance variable name refers to "Alice"
    // Assignment allowed, both sides of type Person


    g= new Grandmother("Alice", "Margaret, Eleanor, Susan",
		       "Rachel, Katie, Hannah");
    // YOUR COMMENTS HERE
    // new instance of class Grandmother created
    // Grandmother(String n, String dL, string gDL) (rule 1)
    // Mother(String n, String dL) (rule 6)
    // Person(String n) (rule 6, again)
    // instance variable name refers to "Alice"
    // instance variable daughterList refers to "Margaret, Eleanor, Susan"
    // instance variable grandDaughterList refers to "Rachel, Katie, Hannah"
    // Assignment allowed, both sides of type Grandmother

    a= new Aunt("Irene", "Susan, Shirley, Patricia");
    // YOUR COMMENTS HERE
    // new instance of class Aunt created
    // Aunt(String n, String nL) (rule 1)
    // Person(String n) (rule 6)
    // instance variable name refers to "Irene"
    // instance variable nieceList refers to "Susan, Shirley, Patricia"
    // Assignment allowed, since both sides of type Aunt

    p.m1();
    // YOUR COMMENTS HERE
    // m1() method of class Person (rule 1)
    // toString() method of class Person (rule 8)
    // "Name: Alice" output

    m.m2();
    // OUR EXAMPLE COMMENTS
    // m2() of class Mother (rule 1)
    // toString() of class Person (rule 7)
    // "Name: Alice" output

    g.m3();
    // YOUR COMMENTS HERE
    // m3() of class Grandmother (rule 1)
    // m2() of class Mother (rule 7)
    // toString() of class Person (rule 7)
    // "Name: Alice" output

    m= g;
    // YOUR COMMENTS HERE
    // Assignment allowed, type of LHS is
    // a superclass of RHS (rule 2)

    m.m2();
    // YOUR COMMENTS HERE
    // m2() of class Grandmother (rule 1)
    // toString() of class Mother (rule 7)
    // toString() of class Person (rule 7)
    // "Name: Alice"
    // "Daughters: Margaret, Eleanor, Susan" output

    //p.m4(2);
    // OUR EXAMPLE COMMENTS
    // compile-time error: p is of type Person, which has
    // no method m4(int) (rule 5)

    p= a;
    // OUR EXAMPLE COMMENTS
    // Assignment allowed: p's type is superclass
    // of a's type (rule 2)

    ((Aunt)p).m4(2);
    // YOUR COMMENTS here
    // Cast allowed: Aunt is a subclass of Person
    // m4(int) of class Aunt (rule 1)
    // m1() of class Aunt, defined in Person (rule 1)
    // toString() of class Aunt (rule 1)
    // toString() of class Person (rule 7)
    // m1() of class Aunt, defined in Person (rule 1)
    // toString() of class Aunt (rule 1)
    // toString() of class Person (rule 7)
    // "Name: Irene"
    // "Nieces: Susan, Shirley, Patricia"
    //
    // "Name: Irene"
    // "Nieces: Susan, Shirley, Patricia" output

    m.m1();
    // YOUR COMMENTS HERE
    // m1() of class Grandmother, defined in Person (rule 1)
    // toString() method of Grandmother (rules 1 & 8)
    // toString() method of Mother (rule 7)
    // toString() method of Person (rule 7)
    // "Name: Alice"
    // "Daughters: Margaret, Eleanor, Susan"
    // "Grandchildren: Rachel, Katie, Hannah" output

    //m= (Mother) p;
    // YOUR COMMENTS HERE
    // run-time error, since RHS casts
    // an instance of type Aunt to type Mother,
    // which is not a superclass of Aunt (rule 4)

    // a= (Aunt) m;
    // YOUR COMMENTS HERE
    // compile-time error, since a variable of type
    // Mother cannot be cast to type Aunt, which
    // is neither a superclass nor a subclass of Mother (rule 3)

  }
}

