Question

In this laboratory, we are going to build a base class and a collection of derived...

In this laboratory, we are going to build a base class and a collection of derived classes.

  1. Write the code to implement the class Person. A person has a name, address,telephone number and and E-Mail address. Be sure to include accessor functions to return each of these values.
  2. Create a derived class Student which has a class status (freshman, sophomore, junior, or senior).
  3. Create a derived class Employee which has the attributes office, salary, and date hired.
  4. Now define a class Faculty which is derived from Employee. The attributes for the Faculty class are rank (professor, associate, assistant, lecturer) and status (tenured, tenure-track, visiting, non-tenure-track).
  5. Define a class Staff derived from Employee. Staff has a single attribute indicating the position (job title).
  6. Write a test main program that creates a Person, Student, Employee, Faculty, and Staff object. Use accessor functions on each object to show they are working.

NEED TO CODE IN C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;

class Person //base class
{
private:
string name;
string address;
string telephoneNumber;
string email;

public:
Person(){} //default constructor
Person(string name,string address,string telephoneNumber,string email) //parameterized constructor
{
this->name = name ;
this->address = address;
this->telephoneNumber = telephoneNumber;
this->email = email;
}

//accessor functions
string getName()
{
return name;
}
string getAddress()
{
return address;
}
string getTelephoneNumber()
{
return telephoneNumber;
}
string getEmail()
{
return email;
}

};

class Student :public Person //derived from person class
{
private:
string status;

public:
Student(){}

//parameterized constructor passes arguments to base class constructor
Student(string name,string address,string telephoneNumber,string email,string status):Person(name,address,telephoneNumber,email)
{
this->status = status;
}
string getStatus()
{
return status;
}

};

class Employee :public Person
{
private:
string office;
double salary;
string dateHired;

public:
Employee(){}

//parameterized constructor passes arguments to base class constructor
Employee(string name,string address,string telephoneNumber,string email,string office,double salary,string dateHired):Person(name,address,telephoneNumber,email)
{
this->office = office;
this->salary = salary;
this->dateHired = dateHired;
}
string getOffice()
{
return office;
}
double getSalary()
{
return salary;
}
string getDateHired()
{
return dateHired;
}
};

class Faculty :public Employee
{
private:
string rank;
string status;

public:
Faculty(){}

//parameterized constructor passes arguments to base class constructor
Faculty(string name,string address,string telephoneNumber,string email,string office,double salary,string dateHired,string rank,string status):Employee(name,address,telephoneNumber,email,office,salary,dateHired)
{
this->rank =rank;
this->status = status;
}
string getRank()
{
return rank;
}
string getStatus()
{
return status;
}


};

class Staff : public Employee
{
private :
string position;


public:
Staff(){}
Staff(string name,string address,string telephoneNumber,string email,string office,double salary,string dateHired,string position):Employee(name,address,telephoneNumber,email,office,salary,dateHired)
{
this->position = position;
}
string getPosition()
{
return position;
}

};

int main()
{
Person person1("Nicholos Moore","45,Downtown,NYC","0797877877","[email protected]");
cout<<"Person Address : "<<person1.getAddress();

Student student1("Samara Singh","576 LA","6769704","[email protected]","freshman");
cout<<"\nStudent Name : "<<student1.getName();

Employee employee1("John Smith","6465 street no 2,NYC","987564543","[email protected]","office No 1",5465.00,"January 14,2009");
cout<<"\nEmployee telephone : "<<employee1.getTelephoneNumber();

Staff staff1("Candy Williams","6235 street no 7,NYC","9872222543","[email protected]","office No 4",3460.00,"March 20,2001","Clerk");
cout<<"\n Staff office : "<<staff1.getOffice();
Faculty faculty1("Dr. David louis","345-Hillside,NJ","0123-66688797","[email protected]","Physics Department",8970.00,"september 25,2011","professor","tenured");

cout<<"\nFaculty Name : "<<faculty1.getName()<<"\nAddress : "<<faculty1.getAddress()<<"\nStatus : "<<faculty1.getStatus();

cout<<"\nSalary : "<<faculty1.getSalary();
return 0;
}

output;

Student Name : Samara Singh

Employee Telephone : 987564543

Staff Office : office No 4

Faculty Name : Dr. David louis

Address: 345,Hillside NJ

Status : tenured

Salary : 8970

Add a comment
Know the answer?
Add Answer to:
In this laboratory, we are going to build a base class and a collection of derived...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee

    In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....

  • a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person...

    a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...

  • Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...

    Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...

  • Part I: (The Myate class) Design a class named MyDate. The class contains: • The data...

    Part I: (The Myate class) Design a class named MyDate. The class contains: • The data fields year, month, and day that represent a date. Month is 0-based, i.e., 0 is for January. • A no-arg constructor that creates a MyDate object for the current date. • A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1, 1970, in milliseconds. • A constructor hat constructs a MyDate object with the specified year, month, and...

  • Please provide the code for the last part(client side program). yes i have all the class...

    Please provide the code for the last part(client side program). yes i have all the class implementations. ``` person.h #ifndef PERSON_H #define PERSON_H #include <string> using namespace std; class person { public: person(); string getname() const; string getadd() const; string getemail() const; string getphno() const; string toString() const; private: string name; string add; string email; string phno; }; ```person.cpp #include "person.h" person::person() { name = "XYZ"; add="IIT "; email="%%%%"; phno="!!!!!"; } string person::getname() const { return name; } string person::getadd()...

  • Java Programming Design a class named Person and its two subclasses named Student and Employee. A...

    Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....

  • Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman...

    Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...

  • Create a class hierarchy to be used in a university setting. The classes are as follows:...

    Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...

  • Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define...

    Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...

  • Define an example of inheritance with a base class that has 2 attributes, 2 derived classes...

    Define an example of inheritance with a base class that has 2 attributes, 2 derived classes that each have 2 attributes. Implement this in C++. Create a driver program that creates instances of both of the derived classes and exercises the classes’ member functionsl. Student answer should include the following: 1 base class with 2 attributes, 2 constructors (default and with parameters), get/set methods for each attribute, and display methods 2 derived classes with 2 attributes, 2 constructors (default and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT