Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include "student.h"
- using namespace std;
- student::student() {
- name = "No-name";
- major = "Mo-major";
- byear = 1950;
- hours = 0;
- }
- student::student(string n, string m, int b, int h) {
- name = n;
- major = m;
- if (byear >= 1950 && byear <= 2000)
- byear = b;
- if (hours >= 0 && hours < 200)
- hours = h;
- }
- void student::setName(string n) {
- name = n;
- }
- void student::setMajor(string m) {
- major = m;
- }
- void student::setBirthYear(int b) {
- byear = b;
- }
- void student::setCompletedHours(int h) {
- hours = h;
- }
- string student::getName() const {
- return name;
- }
- string student::getMajor() const {
- return major;
- }
- int student::getBirthYear() const {
- return byear;
- }
- int student::getCompletedHours() const {
- return hours;
- }
- void student::print() const {
- cout << "name:" << name << endl;
- cout << "major:" << major << endl;
- cout << "birth year:" << byear << endl;
- cout << "hours completed:" << hours << endl;
- }
- bool hasGPA(undergraduate a1,float a) {
- if (a1.gpa == a)
- return true;
- else
- return false;
- }
- undergraduate::undergraduate() {
- gpa = 0.0;
- gproject = "";
- }
- undergraduate::undergraduate(float g, string p, string n, string m, int b, int h):student(n,m,b,h) {
- gpa = g;
- gproject = p;
- }
- void undergraduate::setGPA(float g) {
- gpa = g;
- }
- void undergraduate::setGraduation_project(string p) {
- gproject = p;
- }
- float undergraduate::getGPA() const {
- return gpa;
- }
- string undergraduate::getGraduation_project() const {
- return gproject;
- }
- void undergraduate::print() const {
- cout << "GPA" << gpa << endl;
- cout << "Graduation project:" << gproject << endl;
- student::print();
- }
- graduate::graduate() {
- isTA = false;
- thesis_name = "";
- }
- graduate::graduate(bool t, string n, string l, string m, int b, int h):student(l, m, b, h) {
- isTA = t;
- thesis_name = n;
- }
- void graduate::setTA(bool t) {
- isTA = t;
- }
- void graduate::setThesisName(string n) {
- thesis_name = n;
- }
- bool graduate::getTA() const {
- return isTA;
- }
- string graduate::getThesisName() const {
- return thesis_name;
- }
- void graduate::print() const {
- cout << "is TA?" << isTA << endl;
- cout << "Thesis Name:" << thesis_name << endl;
- student::print();
- }
- void graduate::getMajor() {
- cout<<student::getMajor()<<"GRADUATE"<<endl;
- }
- --------------------------------------------------------
- #include <iostream>
- #include <string>
- #include "student.h"
- using namespace std;
- int main() {
- string a, b, c;
- float d=0.0;
- int e=0,f=0;
- bool g;
- cin >> a >> b >> c >> d >> e;
- undergraduate u1(d,a,b,c,d,e) ;
- cin >>g>> a >> b >> c >> f >>e;
- graduate g1(g, a, b, c, f, e);
- u1.print();
- g1.print();
- d = 0.0;
- bool h;
- h = hasGPA(u1, d);
- if (h)
- cout << "has same gpa" << endl;
- else
- cout << "doesnt have same gpa" << endl;
- g1.getMajor();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement