Advertisement
Guest User

Untitled

a guest
May 12th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. /*
  6. class Date
  7. {
  8. private:
  9. int year, month, day;
  10. public:
  11. Date(int y, int m, int d) { year = y; month = m; day = d; }
  12. bool operator=(const Date d)
  13. {
  14.  
  15. }
  16.  
  17. };
  18. */
  19.  
  20. class MyObject
  21. {
  22. virtual MyObject* clone()=0;
  23. virtual string toString()=0;
  24.  
  25. };
  26.  
  27.  
  28. class UniMember:MyObject
  29. {
  30. private:
  31. string name, e_mail, dob;
  32.  
  33. public:
  34. UniMember(string n, string e, string d);
  35. virtual void print();
  36. string toString() final override;
  37. };
  38.  
  39. void UniMember::print(){
  40. cout << "UniMember name: "<<name<<endl;
  41. cout << "UniMember e_mail: "<<e_mail<<endl;
  42. cout << "dob: "<<dob<<endl;
  43. }
  44.  
  45. UniMember::UniMember(string n, string e, string d)
  46. : name(n), e_mail(e), dob(d)
  47. {
  48. cout << "UniMem init" << endl;
  49. }
  50.  
  51.  
  52. class Student : public UniMember
  53. {
  54. private:
  55. int admissionYear;
  56. list<string> courses;
  57.  
  58. public:
  59. Student(string n, string e, string d, int y, list<string> coursesList);
  60. virtual void print();
  61.  
  62. };
  63. void Student :: print (){
  64. cout <<"Student Admission Year: "<<admissionYear<<endl;
  65. }
  66. Student :: Student(string n, string e, string d, int y, list<string> coursesList)
  67. : UniMember(n, e, d), admissionYear(y), courses(coursesList)
  68. {
  69. cout << "student init" << endl;
  70. }
  71.  
  72. class Teacher : public UniMember
  73. {
  74. private:
  75. list<string> courses;
  76.  
  77. public:
  78. Teacher(string n, string e, string d, list<string> coursesList);
  79. virtual void print();
  80.  
  81. };
  82. void Teacher :: print(){
  83. UniMember::print();
  84. //print courses
  85. }
  86. Teacher :: Teacher(string n, string e, string d, list<string> coursesList)
  87. : UniMember(n, e, d), courses(coursesList)
  88. {
  89. cout << "teacher init" << endl;
  90. }
  91.  
  92. void test1()
  93. {
  94. UniMember* pUniMember;
  95. list<string> L = { "maths", "c++", "stuff" };
  96. pUniMember = new Student{"John", "john@stud.com", "1827-05-28", 1997, L};
  97.  
  98. list<string> tL = { "theory of something", "physics" };
  99. pUniMember = new Teacher {"Peter", "boss@uni.ro", "1672-02-12", tL};
  100. pUniMember->print();
  101.  
  102. Teacher* pTeacher;
  103. pTeacher = new Teacher {"Ralph", "ralph@uni.ro", "1972-02-12", tL};
  104. // pTeacher = new UniMember { ""}
  105. }
  106.  
  107. void test_lab10_1(){
  108. list<UniMember*>uList;
  109. list<string> L = { "maths", "c++", "stuff" };
  110. list<string> tL = { "theory of something", "physics" };
  111. uList.push_back(new Teacher{"Peter", "boss@uni.ro", "1672-02-12", tL});
  112. uList.push_back(new Student{"John", "john@stud.com", "1827-05-28", 1997, L});
  113. uList.push_back(new UniMember{"DASAS","asd@asd.com","123-123-123"});
  114. for (list<UniMember*>::iterator it = uList.begin();it!=uList.end();++it){
  115. (*it)->print();
  116. cout << endl;
  117. }
  118. }
  119.  
  120. void testNotInst(){
  121. UniMember{"ASDAWD","asd22@a22sd.com","123-123-123"};
  122.  
  123. }
  124.  
  125. string UniMember::toString(){
  126. return string("abc");
  127. }
  128.  
  129. int main()
  130. {
  131. // UniMember Andrew{"Andrew", "andrew@uni.com", "2017-04-12"};
  132. //
  133. // list<string> L = { "maths", "c++", "stuff" };
  134. // Student John{"John", "john@stud.com", "1827-05-28", 1997, L};
  135. //
  136. // list<string> tL = { "theory of chibrit", "boring stuff III" };
  137. // Teacher Peter{"Peter", "boss@uni.ro", "1672-02-12", tL};
  138. return 0;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement