1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
#include <cstdlib>
#include <iostream>
#define MAX_CLASSES 2
#define TUITION 1000
using namespace std;
enum department {admin, academic};
string Department (department);
enum jobStatus {fulltime, parttime};
string jStatus (jobStatus);
enum gender {male, female, Private};
string Gender(gender);
struct person {
string name;
gender sex;
int age;
person(string s, gender g, int a): name(s), sex(g), age(a){};
person(){};
string prefix();
};
class student : public person {
bool registered;
string* classes;
int balance;
int classCount;
public:
void enroll(string course);
void printClasses();
student(){registered = false; classes = new string[MAX_CLASSES];
balance = 0; classCount = 0;};
int accountBalance() {return balance;};
void payBalance(float&);
void print();
};
class employee : public person {
private:
department dept;
jobStatus status;
int salary;
public:
void promote(int raise) {salary += raise;};
employee (department d, jobStatus js, int pay): dept(d), status(js), salary(pay) {};
employee();
};
int main(int argc, char** argv)
{
float UTuitionBalance = 0;
person student2("Jane Doe", female, 20);
student student1;
student1.name = "John Doe";
student1.age = 18;
student1.sex = male;
student1.enroll("CSCI-270");
student1.enroll("CSCI-260");
cout << student1.prefix() << student1.name << " is enrolled in: ";
student1.printClasses();
cout << "\n\n";
cout << student1.name << " currently owes $";
cout << student1.accountBalance() << "\n\n";
system ("PAUSE");
return EXIT_SUCCESS;
}
string Gender(gender g)
{
switch (g)
{
case 0: return "male";
break;
case 1: return "female";
break;
default: return "private";
break;
}
}
string person::prefix()
{
switch (sex)
{
case male: return "Mr.";
break;
case female: return "Ms.";
break;
default: return " ";
break;
}
}
void student::enroll (string course)
{
registered = true;
if (classCount == MAX_CLASSES)
{
cout << "\n\n Maximun number of classes reached for ";
cout << this->prefix() << this -> name;
cout << "\n You must delete one or more Classes to enroll.\n\n";
}
else
{
classes[classCount] = course;
++classCount;
balance += TUITION;
}
}
void student::printClasses()
{
if (registered)
for (int count = 0; count < classCount; count++)
cout << "\n" << classes[count] << endl;
}
void student::payBalance(float& b)
{
if (balance > 0)
{
b += balance;
balance = 0;
}
}
void student::print()
{
if (registered == false)
cout << this ->prefix() << this ->name << " is not registered. \n\n";
else
{
cout << this ->prefix() << this ->name << " is registered for the ";
cout << " following classes : \n\n";
this->printClasses();
cout << "\nThe balance due is: " << this -> balance << endl;
}
}
string Department (department d)
{
switch (d)
{
case admin: return "Administration";
break;
case academic: return "Academic";
break;
default: return "Unknown Department";
}
}
string jStatus (jobStatus j)
{
switch (j)
{
case fulltime: return "Full time";
break;
case parttime: return "Part time";
break;
default: return "Unknown Job Status";
}
}
|