FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-projects/OOP2_Lab2/Source.cpp at master · raz0229/cpp-projects · GitHub
raz0229
/
cpp-projects
Public
forked from
Rustam-Z/cpp-programming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-projects
/
OOP2_Lab2
/
Source.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
246 lines (214 loc) · 4.37 KB
Breadcrumbs
cpp-projects
/
OOP2_Lab2
/
Source.cpp
Copy path
File metadata and controls
246 lines (214 loc) · 4.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#
include
<
iostream
>
#
include
<
string
>
using
namespace
std
;
//
Program #1
class
Person
{
private:
string name;
int
age;
public:
Person
() {
//
default constructor
age =
17
;
name =
"
Rustam
"
;
}
Person
(
int
x ) {
age = x;
name =
"
Rustam
"
;
}
void
Display
() {
cout <<
"
Name:
"
<< name << endl;
cout <<
"
Age:
"
<< age << endl;
}
};
//
Program #2
class
Records
{
private:
string name;
float
salary;
string date_of_birth;
public:
Records
() {
name =
"
Rustam
"
;
salary =
1234
;
date_of_birth =
"
12.34.5678
"
;
}
Records
(string name1,
float
salary1, string date_of_birth1) {
name = name1;
salary = salary1;
date_of_birth = date_of_birth1;
}
void
Display
() {
cout << endl;
cout <<
"
Name:
"
<< name << endl;
cout <<
"
Salary:
"
<< salary <<endl;
cout <<
"
Date of Birth:
"
<< date_of_birth <<endl;
}
void
alert_name
() {
cout <<
"
New name:
"
;
cin >> name;
}
void
alert_salary
() {
cout <<
"
New salary:
"
;
cin >> salary;
}
void
alert_date
() {
cout <<
"
New Date of Birth:
"
;
cin >> date_of_birth;
}
};
//
Program #3
class
Account
{
public:
Account
() {
cout <<
"
Object is being Created
"
<< endl;
name =
"
Rustam
"
;
number =
"
123456789
"
;
balance =
12345
;
}
~Account
() {
cout <<
"
Object is being Deleted
"
<< endl;
}
void
Display
() {
cout <<
"
Name:
"
<< name << endl <<
"
Number:
"
<< number << endl <<
"
Balance:
"
<< balance << endl;
}
private:
string name;
string number;
float
balance;
};
//
Program #4
class
Rectangle
{
private:
double
height;
double
width;
public:
Rectangle
() {
height =
5
;
width =
5
;
}
Rectangle
(
double
height2,
double
width2) {
height = height2;
width = width2;
}
void
setHeight
(
double
a) {
height = a;
}
double
getHeight
() {
return
height;
}
void
setWidth
(
double
b) {
width= b;
}
double
getWidht
() {
return
width;
}
double
getArea
() {
return
width * height;
}
double
getPerimeter
() {
return
2
* (width + height);
}
};
void
main_menu_view
() {
cout <<
"
Main menu:
\n
"
;
cout <<
"
[1] Person's info
\n
"
;
cout <<
"
[2] Records
\n
"
;
cout <<
"
[3] Account
\n
"
;
cout <<
"
[4] Triangle
\n
"
;
cout <<
"
[0] Exit
\n
"
;
cout <<
"
Your Choice:
"
;
}
int
main
() {
string user_choise;
main_menu_view
();
cin >> user_choise;
//
main_menu_validation_check
if
(user_choise ==
"
1
"
) {
system
(
"
cls
"
);
int
x;
cout <<
"
Input Age:
"
;
cin >> x;
Person person1,
person2
(x);
person1.
Display
();
cout << endl;
person2.
Display
();
}
else
if
(user_choise ==
"
2
"
) {
system
(
"
cls
"
);
cout <<
"
Records:
"
<< endl;
string name;
float
salary;
string date_of_birth;
cout <<
"
Name:
"
;
cin >> name;
cout <<
"
Salary:
"
;
cin >> salary;
cout <<
"
Date of birth:
"
;
cin >> date_of_birth;
Records record1,
record2
(name, salary, date_of_birth);
record1.
Display
();
record2.
Display
();
cout << endl;
Records * ptr = &record1;
ptr->
alert_name
();
ptr->
alert_salary
();
ptr->
alert_date
();
record1.
Display
();
record2.
Display
();
}
else
if
(user_choise ==
"
3
"
) {
system
(
"
cls
"
);
Account a;
a.
Display
();
a.
~Account
();
}
else
if
(user_choise ==
"
4
"
) {
system
(
"
cls
"
);
Rectangle r;
double
width1, height1;
cout <<
"
Enter the widht fo the rectangle:
"
;
cin >> width1;
cout <<
"
Enter the height fo the rectangle:
"
;
cin >> height1;
Rectangle
r2
(height1, width1);
r2.
setHeight
(height1);
r2.
setWidth
(width1);
system
(
"
cls
"
);
int
user_choice_1;
/*
int qwerty;
cin >> qwerty;
*/
while
(user_choice_1 >=
1
)
{
cout <<
"
Rectangle:
\n
"
;
cout <<
"
[1] Area
\n
"
;
cout <<
"
[2] Perimeter
\n
"
;
cout <<
"
[0] Exit
\n
"
;
cin >> user_choice_1;
switch
(user_choice_1)
{
case
1
:
system
(
"
cls
"
);
cout <<
"
The Area is: (Default Constructor (5,5)) :
"
<< r.
getArea
() << endl << endl;
cout <<
"
The Area is: (Parametric Constructor) :
"
<< r2.
getArea
() << endl;
cout << endl;
break
;
case
2
:
system
(
"
cls
"
);
cout <<
"
The Perimeter is: (Default Constructor(5,5) :
"
<< r.
getPerimeter
() << endl << endl;
cout <<
"
The Perimeter is: (Parametric Constructor) :
"
<< r2.
getPerimeter
() << endl;
break
;
case
0
:
break
;
}
}
}
else
if
(user_choise ==
"
0
"
) {
return
0
;
}
else
{
system
(
"
cls
"
);
cout <<
"
Please try again !!!
\n
"
;
main
();
}
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL