//
// NAME
// person.h
//
// DESCRIPTION
// This file contains the type definitions and function prototypes
// exported by the Person module.
//
#ifndef _person_h_
#define _person_h_
//
// Include files.
//
#include <string.h>
#include <iostream.h>
//
// NAME
// person
//
// DESCRIPTION
// This abstract class models a person.
//
// DATA MEMBERS
// name (protected) - person's name.
//
// FUNCTION MEMBERS
//
// person()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// person(const person& p)
// Copy constructor.
// Parameters: p (in) - source person.
// Returns: (none)
//
// clone()
// This pure virtual function clones the person.
// Parameters: (none)
// Returns: pointer to a copy of the person.
//
// read()
// This pure virtual function reads the information about
// the person.
// Parameters: (none)
// Returns: (none)
//
// display()
// This pure virtual function displays the information about
// the person.
// Parameters: (none)
// Returns: (none)
//
// readName()
// This function reads the person's name.
// Parameters: (none)
// Returns: (none)
//
// displayName()
// This function displays the person's name.
// Parameters: (none)
// Returns: (none)
//
// MEMBER CONSTANTS
// nameLen - maximum length of the person's name.
//
class person {
public:
person() { strcpy(name, ""); }
person(const person& p) { strcpy(name, p.name); }
virtual person * clone() const = 0;
virtual void read() = 0;
virtual void display() const = 0;
void readName();
void displayName() const;
enum { nameLen = 20 };
protected:
char name[nameLen+1];
};
//
// NAME
// academic
//
// DESCRIPTION
// This class models an academic object.
//
// DATA MEMBERS
// department (protected) - acedemic's object.
//
// FUNCTION MEMBERS
//
// academic()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// academic(const academic& p)
// Copy constructor.
// Parameters: a (in) - source academic.
// Returns: (none)
//
// readDept()
// This function reads the academic's department.
// Parameters: (none)
// Returns: (none)
//
// displayDept()
// This function displays the academic's department.
// Parameters: (none)
// Returns: (none)
//
// MEMBER CONSTANTS
// deptLen - maximum length of the academic's department.
//
class academic {
public:
academic() { strcpy(dept, ""); }
academic(const academic& a) { strcpy(dept, a.dept); }
void readDept();
void displayDept() const;
enum { deptLen = 4 };
protected:
char dept[deptLen+1];
};
//
// NAME
// industry
//
// DESCRIPTION
// This class models an industry object.
//
// DATA MEMBERS
// company (protected) - industry's company name.
//
// FUNCTION MEMBERS
//
// industry()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// industry(const industry& i)
// Copy constructor.
// Parameters: i (in) - source industry.
// Returns: (none)
//
// readCompany()
// This function reads the industry's company name.
// Parameters: (none)
// Returns: (none)
//
// displayCompany()
// This function displays the industry's company name.
// Parameters: (none)
// Returns: (none)
//
// MEMBER CONSTANTS
// companyLen - maximum length of the industry's company name.
//
class industry {
public:
industry() { strcpy(company, ""); }
industry(const industry& i) { strcpy(company, i.company); }
void readCompany();
void displayCompany() const;
enum { companyLen = 15 };
protected:
char company[companyLen+1];
};
//
// NAME
// employee
//
// DESCRIPTION
// This class models a employee. It is derived from person.
//
// DATA MEMBERS
// salary (protected) - employee's salary.
//
// FUNCTION MEMBERS
//
// employee()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// employee(const employee& e)
// Copy constructor.
// Parameters: e (in) - source employee.
// Returns: (none)
//
// readSalary()
// This function reads the employee's salary.
// Parameters: (none)
// Returns: (none)
//
// displaySalary()
// This function displays the employee's salary.
// Parameters: (none)
// Returns: (none)
//
class employee : public person {
public:
employee() { salary = 0; }
employee(const employee& e) { salary = e.salary; }
void readSalary();
void displaySalary() const;
protected:
int salary;
};
//
// NAME
// student
//
// DESCRIPTION
// This class models a student. It is derived from person
// and academic.
//
// FUNCTION MEMBERS
//
// student()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// student(const student& s)
// Copy constructor.
// Parameters: s (in) - source student.
// Returns: (none)
//
// clone()
// This virtual function clones the student.
// Parameters: (none)
// Returns: pointer to a copy of the student.
//
// read()
// This virtual function reads the information about
// the student.
// Parameters: (none)
// Returns: (none)
//
// display()
// This virtual function displays the information about
// the student.
// Parameters: (none)
// Returns: (none)
//
class student : public person, public academic {
public:
student() { ; }
student(const student& s);
person * clone() const;
void read();
void display() const;
};
//
// NAME
// instructor
//
// DESCRIPTION
// This class models a student. It is derived from employee
// and academic.
//
// FUNCTION MEMBERS
//
// instructor()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// instructor(const instructor& i)
// Copy constructor.
// Parameters: i (in) - source instructor.
// Returns: (none)
//
// clone()
// This virtual function clones the instructor.
// Parameters: (none)
// Returns: pointer to a copy of the instructor.
//
// read()
// This virtual function reads the information about
// the instructor.
// Parameters: (none)
// Returns: (none)
//
// display()
// This virtual function displays the information about
// the instructor.
// Parameters: (none)
// Returns: (none)
//
class instructor : public employee, public academic {
public:
instructor() { ; }
instructor(const instructor& i);
person * clone() const;
void read();
void display() const;
};
//
// NAME
// programmer
//
// DESCRIPTION
// This class models a programmer. It is derived from employee
// and industry.
//
// FUNCTION MEMBERS
//
// programmer()
// Default constructor.
// Parameters: (none)
// Returns: (none)
//
// programmer(const programmer& p)
// Copy constructor.
// Parameters: p (in) - source programmer.
// Returns: (none)
//
// clone()
// This virtual function clones the programmer.
// Parameters: (none)
// Returns: pointer to a copy of the programmer.
//
// read()
// This virtual function reads the information about
// the programmer.
// Parameters: (none)
// Returns: (none)
//
// display()
// This virtual function displays the information about
// the programmer.
// Parameters: (none)
// Returns: (none)
//
class programmer : public employee, public industry {
public:
programmer() { ; }
programmer(const programmer& p);
person * clone() const;
void read();
void display() const;
};
#endif