-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeekState.cpp
More file actions
38 lines (35 loc) · 871 Bytes
/
WeekState.cpp
File metadata and controls
38 lines (35 loc) · 871 Bytes
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
#include <iostream>
#include "WeekState.hpp"
using namespace std;
void WeekState::update(const Calendar& calendar, int num) {
int count = 1;
int finalNum = num + 7;
for(int j = num; j < finalNum; ++j) {
if(j > 365) {
j = 0;
finalNum = num - 365 + 6;
}
int numDays = j;
int monthCount = 1;
int daysToMonth[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
for(int i = 0; i < 11; ++i) {
numDays -= daysToMonth[i];
if(numDays < 0) {
numDays += daysToMonth[i];
break;
}
monthCount++;
}
cout << monthCount << "/" << numDays + 1 << endl;
if(calendar.getDay(j).size() != 0) {
for(auto ev : calendar.getDay(j)) {
cout << count << ". " << ev -> getName() << endl;
count++;
}
}
else {
cout << "No events" << endl;
}
cout << endl;
}
}