Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Person
- {
- protected:
- string name;
- string surname;
- public:
- //კონსტრუქტორი პიროვნების ობიექტისა
- Person(string name, string surname)
- {
- this->name = name;
- this->surname = surname;
- }
- ~Person() {};
- void printInfo() {
- cout << "---------------------" << endl;
- cout << "\tPerson\t" << endl;
- cout << "Name - " << name << endl;
- cout << "Surname - " << surname << endl;
- cout << "---------------------" << endl;
- cout << endl;
- }
- };
- class Student : public Person
- {
- protected:
- string speciality;
- float GPA;
- public:
- //კონსტრუქტორი სტუდენტ ობიექტისა
- Student(string name, string surname, string speciality, float GPA) :
- Person(name, surname)
- {
- this->speciality = speciality;
- this->GPA = GPA;
- }
- ~Student() {};
- void printInfo() {
- cout << "---------------------" << endl;
- cout << "\tStudent\t" << endl;
- cout << "Name - " << name << endl;
- cout << "Surname - " << surname << endl;
- cout << "Speciality - " << speciality << endl;
- cout << "GPA - " << GPA << endl;
- cout << "---------------------" << endl;
- cout << endl;
- }
- void setSpeciality(){
- cout << "Enter the students speciality : ";
- cin >> speciality;
- cout << endl << "Speciality has been set!" << endl;
- cout << endl;
- }
- };
- class Employee : public Student
- {
- protected:
- string job;
- double salary;
- public:
- //კონსტრუქტორი თანამშრომლის ობიექტისა
- Employee(string name, string surname, string speciality, float GPA, string job, double salary):
- Student(name, surname, speciality, GPA)
- {
- this->job = job;
- this->salary = salary;
- }
- ~Employee() {};
- void printInfo() {
- cout << "---------------------" << endl;
- cout << "\tEmployee\t" << endl;
- cout << "Name - " << name << endl;
- cout << "Surname - " << surname << endl;
- cout << "Speciality - " << speciality << endl;
- cout << "GPA - " << GPA << endl;
- cout << "Job - " << job << endl;
- cout << "Salary - " << salary << endl;
- cout << endl;
- cout << "---------------------" << endl;
- }
- void setSalary() {
- if (salary < 1000)
- salary *= 2;
- else
- salary = salary;
- }
- };
- int main()
- {
- Person person_("Nick", "Sidiani");
- person_.printInfo();//დაიბეჭდევა ინფორმაცია
- person_.~Person();//დესტრუქტორი ამუშავდება
- Student student_("Buba", "Arxiani", "Coding", 3.1);
- student_.printInfo();//დაიბეჭდევა ინფორმაცია
- student_.setSpeciality();//სპეციალობა შეიცვლება კლავიატურიდან შემოტანილით
- student_.printInfo();//დაიბეჭდევა ინფორმაცია
- student_.~Student();//დესტრუქტორი ამუშავდება
- Employee employee_("Giorgi", "Giorgadze", "Cooking", 1.7, "Chef", 800);
- employee_.printInfo();//დაიბეჭდევა ინფორმაცია
- employee_.setSalary();//შეიცვლება ანაზღაურება, თუ 1000-ზე ნაკლებია
- employee_.printInfo();//დაიბეჭდევა ინფორმაცია
- employee_.~Employee();//დესტრუქტორი ამუშავდება
- }
Advertisement
Add Comment
Please, Sign In to add comment