From 8e263d1480c8832a20c863e9db29e5233f8212a1 Mon Sep 17 00:00:00 2001 From: margaret-k <60312043+margaret-k@users.noreply.github.com> Date: Mon, 25 May 2020 23:42:39 +0300 Subject: [PATCH] Create Aspirant --- Aspirant | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 Aspirant diff --git a/Aspirant b/Aspirant new file mode 100644 index 0000000..731f4df --- /dev/null +++ b/Aspirant @@ -0,0 +1,208 @@ +#include +#include +#include + + +using namespace std; + +class Human{ + + protected: + string PIB; // char PIB[20]; + unsigned age; + + bool gender;// true - man, false - woman + public: + + Human(){} + Human(string s, unsigned x, bool g):PIB(s),age(x),gender(g){} + + friend ostream& operator<<(ostream & ost, const Human & h){ + const char* gen = h.gender?"Male":"Female"; + ost << h.PIB << ", " << h.age <<"," << gen<> pib; + cout<<"age:"; + cin>> ag; + cout<<"Male or Female? M/F?"; + string sex; + cin>>sex; + if (tolower(sex[0])=='f'){ + gend =false; + } + else{ + gend =true; + } + + PIB =pib; + age=ag; + gender = gend; + return true; + } + + int getAge(){ + return age; + } + + virtual void show(){ + cout<<*this; + } + +}; + + + +class Student : public Human{ +protected: + string VUZ; + unsigned char kurs; + char grupa[3]; + + public: + + Student(){}; + + Student(string s, unsigned x, bool g, string V, unsigned char k, const char grup[3]):Human(s,x,g){ + VUZ = V; + kurs=k; + strcpy(grupa,grup); // const_cast<...> + } + + + friend ostream& operator<<(ostream & ost, const Student & h){ + const char* gen = h.gender?"Male":"Female"; + ost << h.PIB << " , " << h.age <<" ," << gen<<" VUZ: "<< h.VUZ <<" Kurs: "<> VU; + cout<<"Kurs"; + cin>>kur; + cout<<"Group"; + cin>>grup; + VUZ=VU; + kurs= kur; + + strcpy(grupa,grup); + } + +virtual void show(){ + cout<<*this; +} + +}; + + +class Lecturer: public Human{ +protected: + string VUZ; + + public: + Lecturer(){}; + + Lecturer(string s, unsigned x, bool g, string V):Human(s,x,g){ + VUZ = V; + } + + friend ostream& operator<<(ostream & ost, const Lecturer & h){ + const char* gen = h.gender?"Male":"Female"; + ost << h.PIB << ", " << h.age <<", " << gen<<", " <<" VUZ : "<> VU; + VUZ = VU; + return true; + } + void show(){ + cout<<*this; +} + +}; + + +class Aspirant: public Student{ + string kafedra; +public: +Aspirant(){}; + +Aspirant(string s, unsigned x, bool g, string V, unsigned char kur, const char grup[3], string kaf): Student(s,x,g, V, kur, grup){ + kafedra = kaf; + } + + friend ostream& operator<<(ostream & ost, const Aspirant & h){ + const char* gen = h.gender?"Male":"Female"; + ost << h.PIB << " , " << h.age <<" ," << gen<<" VUZ: "<< h.VUZ <<" Kurs: "<> kaf; + kafedra = kaf; + return true; + } + + void show(){ + cout<<*this; +} +}; + + + +int main(){ +int N=3; + +Human* m1[10]; + + //int N=2; +for(int i=0;i>str; + if (tolower(str[0])=='l'){ + Lecturer* l = new Lecturer(); + l->input(); + + m1[i] =l; + } + if(tolower(str[0])=='s') { + Student* l = new Student; + l->input(); + + m1[i] = l; + } + if(tolower(str[0])=='a'){ + Aspirant* l = new Aspirant; + l->input(); + + m1[i] = l; + } + + + } + for(int i=0;ishow(); + } + +}