erehh

sakontrolo savarjisho 2

Jun 7th, 2022
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Person
  6. {
  7. protected:
  8.     string name;
  9.     string surname;
  10. public:
  11.     Person(string name, string surname)
  12.     {
  13.         this->name = name;
  14.         this->surname = surname;
  15.     }
  16.  
  17.     ~Person() {};
  18.  
  19.     void printInfo() {
  20.         cout << "---------------------" << endl;
  21.         cout << "\tPerson\t" << endl;
  22.         cout << "Name - " << name << endl;
  23.         cout << "Surname - " << surname << endl;
  24.         cout << "---------------------" << endl;
  25.         cout << endl;
  26.     }
  27. };
  28.  
  29. class Student : public Person
  30. {
  31. protected:
  32.     string speciality;
  33.     float GPA;
  34. public:
  35.     Student(string name, string surname, string speciality, float GPA) :
  36.         Person(name, surname)
  37.     {
  38.         this->speciality = speciality;
  39.         this->GPA = GPA;
  40.     }
  41.  
  42.     ~Student() {};
  43.  
  44.     void printInfo() {
  45.         cout << "---------------------" << endl;
  46.         cout << "\tStudent\t" << endl;
  47.         cout << "Name - " << name << endl;
  48.         cout << "Surname - " << surname << endl;
  49.         cout << "Speciality - " << speciality << endl;
  50.         cout << "GPA - " << GPA << endl;
  51.         cout << "---------------------" << endl;
  52.         cout << endl;
  53.     }
  54.  
  55.     void setSpeciality(){
  56.         cout << "Enter the students speciality : ";
  57.         cin >> speciality;
  58.         cout << endl << "Speciality has been set!" << endl;
  59.         cout << endl;
  60.     }
  61.  
  62.  
  63. };
  64.  
  65. class Employee : public Student
  66. {
  67. protected:
  68.     string job;
  69.     double salary;
  70. public:
  71.     Employee(string name, string surname, string speciality, float GPA, string job, double salary):
  72.         Student(name, surname, speciality, GPA)
  73.     {
  74.         this->job = job;
  75.         this->salary = salary;
  76.     }
  77.    
  78.     ~Employee() {};
  79.  
  80.     void printInfo() {
  81.         cout << "---------------------" << endl;
  82.         cout << "\tEmployee\t" << endl;
  83.         cout << "Name - " << name << endl;
  84.         cout << "Surname - " << surname << endl;
  85.         cout << "Speciality - " << speciality << endl;
  86.         cout << "GPA - " << GPA << endl;
  87.         cout << "Job - " << job << endl;
  88.         cout << "Salary - " << salary << endl;
  89.         cout << endl;
  90.         cout << "---------------------" << endl;
  91.     }
  92.  
  93.     void setSalary() {
  94.         if (salary < 1000)
  95.             salary *= 2;
  96.         else
  97.             salary = salary;
  98.     }
  99. };
  100.  
  101. class DynamicEmployee
  102. {
  103. public:
  104.  
  105. };
  106.  
  107. int main()
  108. {
  109.     Person person_("Nick", "Sidiani");
  110.     person_.printInfo();
  111.     person_.~Person();
  112.  
  113.     Student student_("Buba", "Arxiani", "Coding", 3.1);
  114.     student_.printInfo();
  115.     student_.setSpeciality();
  116.     student_.printInfo();
  117.     student_.~Student();
  118.  
  119.     Employee employee_("Giorgi", "Giorgadze", "Cooking", 1.7, "Chef", 800);
  120.     employee_.printInfo();
  121.     employee_.setSpeciality();
  122.     employee_.setSalary();
  123.     employee_.printInfo();
  124.     employee_.~Employee();
  125. }
Advertisement
Add Comment
Please, Sign In to add comment