-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBirthdayCompositonClass.cpp
More file actions
140 lines (100 loc) · 3.19 KB
/
BirthdayCompositonClass.cpp
File metadata and controls
140 lines (100 loc) · 3.19 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <iostream>
#include <string>
using namespace std;
class Point1{
public:
Point1() {
m_x1 = 0; m_y1 = 0;
cout << "Point1 Default Constructor." << endl;
}
Point1(int x1, int y1) {
m_x1 = x1; m_y1 = y1;
cout << "Point1 Start Point Constructor." << endl;
}
Point1(const Point1& old) {
m_x1 = old.m_x1; m_y1 = old.m_y1;
cout << "Point1 Copy Constructor." << endl;
}
~Point1() { //cout << "Birtthday Destructor." << endl;
}
void X(int x1) { m_x1 = x1; }
void Y(int y1) { m_y1 = y1; }
int X() { return m_x1; }
int Y() { return m_y1; }
void Distance1()
{
int distance = m_x1 - m_y1;
cout << distance << endl;
}
void ToString1() { cout<< m_x1 <<"/" <<m_y1 << endl; }
private:
int m_x1; int m_y1;
};
class Birthday{
public:
Birthday() {
month = 0; day = 0; year = 0;
cout << "Birthday Default Constructor." << endl;
}
Birthday(int xmonth, int yday, int zyear) {
month = xmonth; day = yday; year = zyear;
//cout << "Birthday constructor with Start and End Point." << endl;
}
Birthday(const Birthday& old) {
month = old.month; day = old.day; year = old.year;
//cout << "Birtthday Copy Constructor." << endl;
}
~Birthday() { //cout << "Birtthday Destructor." << endl;
}
void X(int x) { month = x; }
void Y(int y) { day = y; }
void Z(int z){ year = z; }
int X() { return month; }
int Y() { return day; }
int Z() { return year; }
void Distance2()
{
int distance = month - day + year;
cout << distance << endl;
//return distance;
}
void ToString2(){ cout<< month <<"/" <<day <<"/" << year <<endl; }
private:
int month; int day; int year;
};
class People{
public:
People() { cout << "People Default Constructor." << endl;}
People(string cname, Birthday cdateOfBirth) :name(cname), dateOfBirth(cdateOfBirth)
{ cout << "People Constructor with End Point." << endl; }
People(string cname, Point1 cObject) :name(cname), Object(cObject)
{ cout << "People Constructor with Start Point." << endl; }
~People() { cout << "People Destructor." << endl; }
void Length()
{
cout<< name << " The distance is: "; dateOfBirth.Distance2();
cout<< name << " The distance is: "; Object.Distance1();
}
void ToString() {
cout<<name <<" was born on: "; dateOfBirth.ToString2();
cout<<name <<" was born on: "; Object.ToString1(); }
private:
string name; Point1 Object; Birthday dateOfBirth;
};
int main()
{
int x,y;
cin >> x; cin >> y;
int a,b,c;
cin >> a; cin >> b; cin >> c;
Point1 StartPoint(x,y);
Birthday EndPoint(a,b,c);
cout << endl << endl;
People infoObject("Start Point Information is: ",StartPoint);
infoObject.ToString();
infoObject.Length();
cout << endl << endl;
People IObject("End Point Information is: ", EndPoint);
IObject.ToString();
IObject.Length();
}