/*
 * File: tester.cpp
 * -------------------
 * This includes code from the CS106X practice final exam #1,
 * problem #5 (Inheritance).
 *
 * (c) Cynthia Lee
 */

#include <iostream>
#include <string>
#include "console.h"
using namespace std;


class Byron {
public:
    virtual void m3() {
        cout << "B 3" << endl;
        m1();
    }
    virtual void m1() {
        cout << "B 1" << endl;
    }
};

class Yeats : public Byron {
public:
    virtual void m3() {
        Byron::m3();
        cout << "Y 3" << endl;
    }
    virtual void m4() {
        cout << "Y 4" << endl;
    }
};

class Plath : public Yeats {
public:
    virtual void m1() {
        cout << "P 1" << endl;
        Yeats::m1();
    }
    void m3() {
        cout << "P 3" << endl;
    }
};

class Angelou : public Plath {
public:
    virtual void m4() {
        cout << "A 4" << endl;
        m3();
    }
    void m3() {
        cout << "A 3" << endl;
    }
};


int main() {

    Byron* var1 = new Plath();
    Yeats* var2 = new Angelou();
    Byron* var3 = new Byron();
    Byron* var4 = new Yeats();
    Yeats* var5 = new Plath();

    /* Section 1 */
    var4->m3();
    var4->m1();
//    var4->m4();       // Compiler error
    var2->m3();
    var2->m1();
    var2->m4();
//    var1->m4();       // Compiler error
    var1->m3();
    var1->m1();
    var5->m1();
    var5->m4();
    var5->m3();

    /* Section 2 */
    ((Yeats*) var4)->m3();
    ((Yeats*) var4)->m4();
//    ((Angelou*) var3)->m4();      // Crash
//    ((Byron*) var5)->m4();        // Compiler error
    ((Plath*) var2)->m3();
    ((Angelou*) var2)->m3();

    return 0;
}
