Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // 02_10_upr_3_oop.cpp
- // ConsoleApplication1
- //
- // Created by Kolev on 2.10.18.
- // Copyright © 2018 Kolev. All rights reserved.
- //
- #include <iostream>
- #include <string>
- using namespace std;
- class Adress {
- private:
- string ulica;
- string kod;
- string grad;
- public:
- Adress();
- Adress(string, string, string);
- explicit Adress(const Adress &);
- ~Adress();
- //set
- void set_ulica(string);
- void set_kod(string);
- void set_grad(string);
- //get
- string get_ulica();
- string get_kod();
- string get_grad();
- void print_info();
- };
- Adress::Adress() {
- this->ulica = "";
- this->kod = "";
- this->grad = "";
- }
- Adress::Adress(string ulica, string kod, string grad) {
- this->ulica = ulica;
- this->kod = kod;
- this->grad = grad;
- }
- Adress::Adress(const Adress &obj) {
- this->ulica = obj.ulica;
- this->kod = obj.kod;
- this->grad = obj.grad;
- }
- Adress::~Adress() {}
- //set
- void Adress::set_ulica(string ulica) {
- this->ulica = ulica;
- }
- void Adress::set_kod(string kod) {
- this->kod = kod;
- }
- void Adress::set_grad(string grad) {
- this->grad = grad;
- }
- //get
- string Adress::get_ulica() {
- return this->ulica;
- }
- string Adress::get_kod() {
- return this->kod;
- }
- string Adress::get_grad() {
- return this->grad;
- }
- void Adress::print_info() {
- cout << "Ulica: " << this->ulica << endl;
- cout << "Poshtenski kod: " << this->kod << endl;
- cout << "Grad: " << this->grad << endl;
- cout << "---------------------------" << endl;
- }
- class Person {
- protected:
- string name;
- string egn;
- enum Gender {
- male, female, unknown
- } gender;
- public:
- Person();
- Person(string, string, string);
- ~Person();
- void set_name(string);
- void set_egn(string);
- void set_gender(string);
- string get_name();
- string get_egn();
- string get_gender();
- void print_information();
- };
- Person::Person() {
- this->name = "";
- this->egn = "";
- this->gender = Gender::male;
- }
- Person::Person(string name, string egn, string gender) {
- this->name = name;
- this->egn = egn;
- if (gender == "male") this->gender = Gender::male;
- else if (gender == "female") this->gender = Gender::female;
- else if (gender == "unknown") this->gender = Gender::unknown;
- }
- Person::~Person() {}
- //set
- void Person::set_name(string name) {
- this->name = name;
- }
- void Person::set_egn(string egn) {
- this->egn = egn;
- }
- void Person::set_gender(string gender) {
- if (gender == "male") this->gender = Gender::male;
- else if (gender == "female") this->gender = Gender::female;
- else if (gender == "unknown") this->gender = Gender::unknown;
- }
- //get
- string Person::get_name() {
- return this->name;
- }
- string Person::get_egn() {
- return this->egn;
- }
- string Person::get_gender() {
- if (gender == Gender::male) return "male";
- else if (gender == Gender::female) return "female";
- else
- return "unknown";
- }
- void Person::print_information() {
- cout << "Ime: " << this->name << endl;
- cout << "EGN: " << this->egn << endl;
- cout << "Pol: " << get_gender() << endl;
- cout << "---------------------------" << endl;
- }
- class Student : public Person {
- private:
- string fn;
- Adress adress;
- public:
- Student();
- Student(string, const Adress &);
- explicit Student(const Student &);
- ~Student();
- void set_fn(string);
- string get_fn();
- void print_info();
- };
- Student::Student() {
- this->fn = "";
- this->adress = Adress();
- }
- Student::Student(string fn, const Adress& adress) {
- this->fn = fn;
- this->adress = adress;
- }
- Student::Student(const Student &obj) {
- this->fn = obj.fn;
- this->adress = obj.adress;
- }
- Student::~Student()
- {
- }
- void Student::set_fn(string fn) {
- this->fn = fn;
- }
- string Student::get_fn() {
- return this->fn;
- }
- void Student::print_info() {
- cout << "Name: " << this->name << endl;
- cout << "FN: " << this->fn << endl;
- this->adress.print_info();
- }
- int main() {
- system("clear");
- Adress adr1("Vqra", "9020", "Varna");
- Adress adr3("Dryzki 27", "9000", "Varna");
- Adress adr2(adr1);
- Student one("17621707", adr3);
- // Person one("Stefan Kolev","9812201049","male");
- one.get_gender();
- one.print_info();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement