// // NAME // person.cpp // // DESCRIPTION // This file contains the function definitions for the member // functions of the person class and global functions which are // related to the person class. // // For descriptions of the parameters and return values, // see person.h. // // // Include files. // #include <iostream.h> #include <string.h> #include "bool.h" #include "person.h" // // NAME // person::readName // // DESCRIPTION // This function reads the name of the person. // void person::readName() { cout << "Enter the person's name (up to " << person::nameLen << " characters): "; cin >> name; } // // NAME // person::displayName // // DESCRIPTION // This function displays the name of a person. // void person::displayName() const { cout << "Name: " << name << endl; } // // NAME // academic::readDept // // DESCRIPTION // This function reads the department of an academic. // void academic::readDept() { cout << "Enter the department (up to " << academic::deptLen << " characters): "; cin >> dept; } // // NAME // academic::displayDept // // DESCRIPTION // This function displays the department of an academic. // void academic::displayDept() const { cout << "Department: " << dept << endl; } // // NAME // industry::readCompany // // DESCRIPTION // This function reads the company name of an industry. // void industry::readCompany() { cout << "Enter the company name (up to " << industry::companyLen << " characters): "; cin >> company; } // // NAME // industry::displayCompany // // DESCRIPTION // This function displays the company name of an industry. // void industry::displayCompany() const { cout << "Company: " << company << endl; } // // NAME // employee::readSalary // // DESCRIPTION // This function reads the salary of an employee. // void employee::readSalary() { cout << "Enter the salary (integer): "; cin >> salary; } // // NAME // employee::displaySalary // // DESCRIPTION // This function display the salary of an employee. // void employee::displaySalary() const { cout << "Salary: " << salary << endl; } // // NAME // student::student // // DESCRIPTION // This is the copy constructor for a student. // student::student(const student& s) { strcpy(name, s.name); strcpy(dept, s.dept); } // // NAME // student::clone // // DESCRIPTION // This function clones a student. // person * student::clone() const { return new student(*this); } // // NAME // student::read // // DESCRIPTION // This function reads the information of a student. // void student::read() { person::readName(); academic::readDept(); } // // NAME // student::display // // DESCRIPTION // This function displays the information of a student. // void student::display() const { cout << endl << "STUDENT" << endl; person::displayName(); academic::displayDept(); } // // NAME // instructor::instructor // // DESCRIPTION // This is the copy constructor for a instructor. // instructor::instructor(const instructor& i) { strcpy(name, i.name); strcpy(dept, i.dept); salary = i.salary; } // // NAME // instructor::clone // // DESCRIPTION // This function clones an instructor. // person * instructor::clone() const { return new instructor(*this); } // // NAME // instructor::read // // DESCRIPTION // This function reads the information of an instructor. // void instructor::read() { employee::readName(); employee::readSalary(); academic::readDept(); } // // NAME // instructor::display // // DESCRIPTION // This function displays the information of an instructor. // void instructor::display() const { cout << endl << "INSTRUCTOR" << endl; employee::displayName(); employee::displaySalary(); academic::displayDept(); } // // NAME // programmer::programmer // // DESCRIPTION // This is the copy constructor for a programmer. // programmer::programmer(const programmer& p) { strcpy(name, p.name); strcpy(company, p.company); salary = p.salary; } // // NAME // programmer::clone // // DESCRIPTION // This function clones a programmer. // person * programmer::clone() const { return new programmer(*this); } // // NAME // programmer::read // // DESCRIPTION // This function reads the information of a programmer. // void programmer::read() { employee::readName(); employee::readSalary(); industry::readCompany(); } // // NAME // programmer::display // // DESCRIPTION // This function displays the information of a programmer. // void programmer::display() const { cout << endl << "PROGRAMMER" << endl; employee::displayName(); employee::displaySalary(); industry::displayCompany(); } // // End of file. //