-
Notifications
You must be signed in to change notification settings - Fork 549
/
Copy path02_homework_02_answer.cpp
69 lines (50 loc) · 1.04 KB
/
02_homework_02_answer.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
59
60
61
62
63
64
65
66
67
68
69
#include <bits/stdc++.h>
using namespace std;
/*
struct DateTime {
int day;
int month;
int year;
int hours;
int minutes;
int seconds;
// Constructor
DateTime(int day, int month, int year,
int hours, int minutes, int seconds) {
}
// A bunch of Time functions
// ...
};
*/
// The problem with above class it is responsible for 2 things
// Date and all its complications
// Time and all its complications
// Always focus a struct on a specific functionality (single responsibility)
// Then, each struct is easier to code
// Easy to give different developers different tasks
struct Date {
int day;
int month;
int year;
// A bunch of Data functions
// ...
};
struct Time {
int hours;
int minutes;
int seconds;
// A bunch of Time functions
// ...
};
struct DateTime {
Date date;
Time time;
// Constructor
DateTime(Date date, Time time) {
}
};
// Design seperate Date & time structs
// Datetime is "composed" of Date and Time
int main() {
return 0;
}