Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include "student.h"
  4. using namespace std;
  5.  
  6. student::student() {
  7.     name = "No-name";
  8.     major = "Mo-major";
  9.     byear = 1950;
  10.     hours = 0;
  11. }
  12. student::student(string n, string m, int b, int h) {
  13.     name = n;
  14.     major = m;
  15.     if (byear >= 1950 && byear <= 2000)
  16.         byear = b;
  17.     if (hours >= 0 && hours < 200)
  18.         hours = h;
  19. }
  20.  
  21. void student::setName(string n) {
  22.     name = n;
  23. }
  24. void student::setMajor(string m) {
  25.     major = m;
  26. }
  27. void student::setBirthYear(int b) {
  28.     byear = b;
  29. }
  30. void student::setCompletedHours(int h) {
  31.     hours = h;
  32. }
  33.  
  34. string student::getName() const {
  35.     return name;
  36. }
  37. string student::getMajor() const {
  38.     return major;
  39. }
  40. int student::getBirthYear() const {
  41.     return byear;
  42. }
  43. int student::getCompletedHours() const {
  44.     return hours;
  45. }
  46.  
  47. void student::print() const {
  48.     cout << "name:" << name << endl;
  49.     cout << "major:" << major << endl;
  50.     cout << "birth year:" << byear << endl;
  51.     cout << "hours completed:" << hours << endl;
  52.    
  53. }
  54.  
  55.  
  56. bool hasGPA(undergraduate a1,float a) {
  57.     if (a1.gpa == a)
  58.         return true;
  59.     else
  60.         return false;
  61.  
  62. }
  63.  
  64.  
  65.  
  66. undergraduate::undergraduate() {
  67.     gpa = 0.0;
  68.     gproject = "";
  69. }
  70. undergraduate::undergraduate(float g, string p, string n, string m, int b, int h):student(n,m,b,h) {
  71.     gpa = g;
  72.     gproject = p;
  73. }
  74. void undergraduate::setGPA(float g) {
  75.     gpa = g;
  76.  
  77. }
  78. void undergraduate::setGraduation_project(string p) {
  79.     gproject = p;
  80. }
  81.  
  82. float undergraduate::getGPA() const {
  83.     return gpa;
  84. }
  85. string undergraduate::getGraduation_project()  const {
  86.     return gproject;
  87. }
  88.  
  89. void undergraduate::print() const {
  90.     cout << "GPA" << gpa << endl;
  91.     cout << "Graduation project:" << gproject << endl;
  92.     student::print();
  93. }
  94.  
  95.  
  96.  
  97.  
  98. graduate::graduate() {
  99.     isTA = false;
  100.     thesis_name = "";
  101. }
  102. graduate::graduate(bool t, string n, string l, string m, int b, int h):student(l, m, b, h) {
  103.     isTA = t;
  104.     thesis_name = n;
  105. }
  106. void graduate::setTA(bool t) {
  107.     isTA = t;
  108. }
  109. void graduate::setThesisName(string n) {
  110.     thesis_name = n;
  111. }
  112.  
  113. bool graduate::getTA() const {
  114.     return isTA;
  115. }
  116. string graduate::getThesisName() const {
  117.     return thesis_name;
  118. }
  119.  
  120. void graduate::print() const {
  121.     cout << "is TA?" << isTA << endl;
  122.     cout << "Thesis Name:" << thesis_name << endl;
  123.    
  124.     student::print();
  125. }
  126.  
  127. void graduate::getMajor() {
  128.     cout<<student::getMajor()<<"GRADUATE"<<endl;
  129.  
  130. }
  131.  
  132.  
  133.  
  134.  
  135. --------------------------------------------------------
  136.  
  137. #include <iostream>
  138. #include <string>
  139. #include "student.h"
  140. using namespace std;
  141.  
  142. int main() {
  143.     string a, b, c;
  144.     float d=0.0;
  145.     int e=0,f=0;
  146.     bool g;
  147.     cin >> a >> b >> c >> d >> e;
  148.     undergraduate u1(d,a,b,c,d,e) ;
  149.    
  150.     cin >>g>> a >> b >> c >> f >>e;
  151.     graduate g1(g, a, b, c, f, e);
  152.  
  153.     u1.print();
  154.     g1.print();
  155.  
  156.     d = 0.0;
  157.     bool h;
  158.     h = hasGPA(u1, d);
  159.     if (h)
  160.         cout << "has same gpa" << endl;
  161.     else
  162.     cout << "doesnt have same gpa" << endl;
  163.  
  164.     g1.getMajor();
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement