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
|
class Time2 {
private:
friend class TimeCard;
string formatted;
int hour;
int minute;
int second;
bool ampm;
public:
Time2() {
}
//overloaded constructor
Time2(int hour, int minute, int second, bool ampm) {
this->hour = hour;
this->minute = minute;
this->second = second;
this->ampm = ampm;
cout << hour << minute << second; //variables are correct here
}
string getCurrentTime() {
formatted = hour << ':' << minute << ':' << second;
return formatted; //hours, minutes, and seconds are random variables, instead of the specified input
}
Tom[1].clockOut(hours, minutes, seconds, ampm);
return 0;
};
class TimeCard : public Time2 {
private:
int punchInH, punchInM, punchInS, punchOutH, punchOutM, punchOutS;
const double RATE = 12.50;
Time2 punchInTime, punchOutTime;
string WorkerID;
double payrate;
bool hasPunched = false;
double hoursWorked;
string sTime, eTime;
public:
TimeCard() {
}
//overloaded constructor
TimeCard::TimeCard(string WorkerID, int h, int m, int s, bool ap) {
if (hasPunched == false)
hasPunched = true;
this->WorkerID = WorkerID;
Time2(h, m, s, ap);
if (hasPunched == true) {
getPunchInTime();
punchInH = getHours();
punchInM = getMinutes();
punchInS = getSeconds();
}
else {
//executes if user has punched out. Logs hours appropriotely.
getPunchOutTime();
punchOutH = getHours();
punchOutM = getMinutes();
punchOutS = getSeconds();
hoursWorked = getHoursWorked();
}
};
//sets time to string
void getPunchInTime() {
sTime = getCurrentTime();
}
//sets time to string
void getPunchOutTime() {
eTime = getCurrentTime();
}
};
int main()
{
//variables initialized...
TimeCard Tom [1] = { TimeCard(iD, hours, minutes, seconds, ampm) };
//variables set differently
Tom[1].clockOut(hours, minutes, seconds, ampm);
return 0;
|