-
Notifications
You must be signed in to change notification settings - Fork 2
/
fakeTime.cpp
59 lines (49 loc) · 970 Bytes
/
fakeTime.cpp
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
/*
* fakeTime.cpp
*
* Created on: Nov 19, 2016
* Author: rocco
*/
#include "fakeTime.h"
fakeTime::fakeTime() : sec(0), min(0), hour(0), day(0) {}
fakeTime::fakeTime(int secIn, int minIn, int hourIn, int dayIn) :
sec(secIn), min(minIn), hour(hourIn), day(dayIn) {}
bool fakeTime::zeros() { return sec==0 && min==0 && hour==0; }
int fakeTime::getSec() { return sec; }
int fakeTime::getMin() { return min; }
int fakeTime::getHour(){ return hour;}
int fakeTime::getDay() { return day; }
void fakeTime::reset()
{
sec=0; min=0; hour=0; day=0;
}
void fakeTime::tick()
{
sec++;
if(sec > 59)
{
sec=0;
min++;
}
if(min > 59)
{
min=0;
hour++;
}
if (hour > 23)
{
hour=0;
day++;
}
}
void fakeTime::print()
{
cout << "Day: " << getDay();
cout << " Hour: " << getHour();
cout << " Min: " << getMin();
cout << " Sec: " << getSec() << endl;
}
fakeTime* fakeTime::copy()
{
return new fakeTime(getSec(), getMin(), getHour(), getDay());
}