//  Programmer:  Anne Dawson
//  Course code: CSCI201A
//  Date:        Tuesday 28th January 2003
//  File name:   personDriver.cpp
//  Problem:     To inherit a Student class from a Person class
//               This program is a tutorial on inheritance


//  The following 2 files are required and must be
//  in the same directory (folder):
//  person.cpp and person.h

//  This file is the "driver" file to test the classes.
//  Notice the class definitions are in the person.h file
//  the class function implementations are in the person.cpp file

//  This driver file tests the classes by calling the class functions.
//  In this code I am creating a Person object and a Student object,
//  and using these objects, call the functions inherited from the Person class.



//  I created this project in Borland C++ 5.02
//  File -> New Project
//  Project Path and name: personDriver.ide (use same path as .cpp files)
//  Target Type: Application[.exe]
//  Platform: Win32
//  Target Model: Console
//  Click on the "Advanced" button and deselect (turn off) the
//  .rc and .def
//	 Click on "OK" to get back to the "New Target" window
//	 Click on "OK" in the "New Target" window

//  You may need to do this:
//  Select from Options menu:
//  Options->Project->Compilers->Precompiled Headers->Do not use or generate

//  In the Projects window click on "personDriver.cpp"
//  From the Project menu select Compile
//  From the Debug menu select Run

//  Whenever you compile, make sure you are currently in the code window
//  for personDriver.cpp - then the other files are automatically included.

#include <iostream.h>
#include <iomanip.h>
#include <conio.h>

#include "person.cpp"  // has to be in the same folder as this file

/**********************************************************************/

int main()
{
   Person person1;    // person1 is an object of the Person class
   Student student1;  // student1 is an object of the Student class

	cout << "Person is:  " << person1.getFirstName() << endl;
   cout << "Student is: " << student1.getFirstName() << endl;
   cout << "Student number is: " << student1.getStudentNumber() << endl << endl;

   // the three lines above show that the constructors
   // have been called correctly
   
   string lastName;
   string firstName;
   string studentNumber;  	cout << "\n\nEnter the first name of the person: ";   cin >> firstName ;   person1.setFirstName(firstName);
  	cout << "Enter the last name of the person: ";
   cin >> lastName ;   person1.setLastName(lastName);   cout << endl << endl << "Person is: " << person1.getFirstName()
                                         << " " << person1.getLastName();

  	cout << "\n\nEnter the first name of the student: ";
   cin >> firstName ;   student1.setFirstName(firstName);
  	cout << "Enter the last name of the student: ";
   cin >> lastName ;   student1.setLastName(lastName);   cout << endl << endl << "Student is: " << student1.getFirstName()
                                          << " " << student1.getLastName();

   // NOTE: the setname and getName functions are functions belonging
   // to the Person class, but because the Student class inherits from
   // the Person class, a student object can call them.

   // NOTE: when the Student class inherits from the Person class, an
   // object of the Student class (e.g. student1) is considered of class
   // Student, but also of class Person. We can say that a student is a person.
   // However, the converse is not true: a person is NOT a student.
   // In OOP terms, we say a student IS-A person, i.e. an object of
   // class Student is also an object of class Person.  This means that
   // a student object can access any public members of the Person class -
   // i.e. can call any public member functions.  We make the Person class's
   // private members into protected members, so that the member variables
   // (fields) can be accessible to any class (e.g. Student) which inherits
   // from Person.

   cout << "\nEnter the student's student number: ";
   cin >> studentNumber ;   student1.setStudentNumber(studentNumber);
   cout << endl << "Student number of student: "
        << student1.getStudentNumber();

   cout << "\n\n\nPress any key to end this program...";
  	getch();

	return 0;

}   /* end main */

/**********************************************************************/


