OOP HomeWork
This commit is contained in:
72
oop_hw5/hw3/person.cpp
Normal file
72
oop_hw5/hw3/person.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include "person.h"
|
||||
|
||||
Person::Person(int a, string n, bool g)
|
||||
{
|
||||
age = a;
|
||||
name = n;
|
||||
gender = g;
|
||||
}
|
||||
|
||||
void Person::change_age(int ca)
|
||||
{
|
||||
age = ca;
|
||||
}
|
||||
|
||||
void Person::change_name(string cn)
|
||||
{
|
||||
name = cn;
|
||||
}
|
||||
|
||||
void Person::change_gender(bool x)
|
||||
{
|
||||
gender = x;
|
||||
}
|
||||
|
||||
int Person::show_age()
|
||||
{
|
||||
return age;
|
||||
}
|
||||
|
||||
string Person::show_name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
bool Person::show_gender()
|
||||
{
|
||||
return gender;
|
||||
}
|
||||
|
||||
void Person::display()
|
||||
{
|
||||
cout << "This is a Person" << endl
|
||||
<< "Name : " << name << endl
|
||||
<< "Age : " << age << endl
|
||||
<< "Gender : ";
|
||||
gender == false ? cout << "Woman" << endl : cout << "Man" << endl;
|
||||
}
|
||||
|
||||
void Employee::add_number(int n)
|
||||
{
|
||||
number = n;
|
||||
}
|
||||
|
||||
void Employee::display()
|
||||
{
|
||||
cout << "This is an Employee" << endl
|
||||
<< "Name : " << this->show_name() << endl
|
||||
<< "Age : " << this->show_age() << endl
|
||||
<< "Gender : ";
|
||||
this->show_gender() == false ? cout << "Woman" << endl : cout << "Man" << endl;
|
||||
cout << "Number ID : " << number << endl;
|
||||
}
|
||||
|
||||
void Executive::display()
|
||||
{
|
||||
cout << "This is an Executive" << endl
|
||||
<< "Name : " << this->show_name() << endl
|
||||
<< "Age : " << this->show_age() << endl
|
||||
<< "Gender : ";
|
||||
this->show_gender() == false ? cout << "Woman" << endl : cout << "Man" << endl;
|
||||
//cout << "Number ID : " << number << endl;
|
||||
}
|
Reference in New Issue
Block a user