-
Notifications
You must be signed in to change notification settings - Fork 0
/
activity.cpp
executable file
·49 lines (42 loc) · 1.04 KB
/
activity.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
#include <vector>
#include <map>
#include <iostream>
#include <set>
#include <ostream>
#include <fstream>
#include <string>
#include "activity.h"
bool Activity::operator==(const Activity& obj) const {
return activity == obj.activity;
}
bool Activity::operator<(const Activity& rhs) const{
if (s < rhs.s) {
return true;
} else if (rhs.s < s) {
return false;
} else {
return e < rhs.e;
}
}
double Activity::getDays() const{
double minutes = 0;
double years = e.year - s.year;
int months = e.month - s.month;
int days = e.day - s.day;
minutes += years * 365 * 24 * 60;
minutes += months * 30 * 24 * 60;
minutes += days * 24 * 60;
int hours = e.hours - s.hours;
int min = e.mins - s.mins;
minutes += hours * 60;
minutes += min;
double num_days = minutes/1440;
return num_days;
}
Activity::Activity(const std::string& n, const double& p, const Date& start, const Date& end, const std::string& l){
activity = n;
price = p;
s = start;
e = end;
link = l;
}