-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dish.cpp
235 lines (201 loc) · 3.03 KB
/
Dish.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
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
#include "Dish.h"
void Dish::editDish()
{
editTitle();
editPrice();
cin.get();
editType();
cin.get();
}
void Dish::editTitle()
{
string tempTitle;
cout << "Please enter the title of dish : ";
cin.ignore();
getline(cin,tempTitle);
setTitle(tempTitle);
}
void Dish::editPrice()
{
double tempPrice;
cout << "Please enter the price of dish : ";
cin >> tempPrice;
setPrice(tempPrice);
}
void Dish::editType()
{
type_dish tempType;
int vibor;
cout << "Enter the type of dish 1=cold, 2 = hot, 3=desert \n";
cin>> vibor;
switch (vibor)
{
case 1:
setType(cold);
break;
case 2:
setType(hot);
break;
case 3:
setType(desert);
break;
default:
break;
}
}
//////////////////////////////////////
Dish Dish::getDish()
{
return *this;
}
type_dish Dish::getType()
{
return type;
}
double Dish::getPrice()
{
return price;
}
string Dish::getTitle()
{
return title;
}
string Dish::pbTitle(string tit)
{
string tnpstr = tit;
for (int i = 0; i< tnpstr.size(); i++)
{
if (tnpstr[i] == '0')
tnpstr[i] = ' ';
}
return tnpstr;
}
string Dish::o0Title(string tit)
{
string str = tit;
for (int i = 0; i< tit.size(); i++)
{
if (str[i] == ' ')
str[i] = '0';
}
return str;
}
/////////////////////////////////////
void Dish::setAll()
{
string t;
double p;
type_dish ty;
cout << "Enter title of dish: \n";
getline(cin, t);
this->setTitle(t);
//cin.get();
cout << "Enter price of dish: \n";
cin >> p;
//cin.get();
this->setPrice(p);
int vibor;
cout << "Enter the type of dish 1=cold, 2 = hot, 3=desert , \n";
cin >> vibor;
switch (vibor)
{
case 1:
this->setType(cold);
break;
case 2:
this->setType(hot);
break;
case 3:
this->setType(desert);
break;
default:
break;
}
cin.get();
}
void Dish::setPrice(double p)
{
if (p>0)
price = p;
else price = 0.1;
}
void Dish::setTitle(string t)
{
if (t.size() < 60 && t.size())
{
title = t;
}
}
void Dish::setType(type_dish t)
{
if (t == cold || t == hot || t == desert||t==untyped) {type = t;}
else
{
return;
}
}
void Dish::setType(string type)
{
if (type == "1")setType(cold);
if (type == "2")setType(hot);
if (type == "3")setType(desert);
if (type == "untyped")setType(untyped);
else return;
}
///////////////////////////////////////
string Dish::printType()
{
switch (type)
{
case cold:
/*cout*/return "Cold dish.";
//break;
case hot:
return "Hot dish. ";
//break;
case desert:
return "Desert.";
//break;
case untyped:
return "Untyped.";
//break;
default:
break;
}
}
bool Dish::equPrice(double _price)
{
if (price == _price)return true;
return false;
}
bool Dish::equTitle(string _Title)
{
if (title == _Title)return true;
return false;
}
bool Dish::equType(type_dish t)
{
if (type == t)return true;
return false;
}
Dish::Dish(string t, double p, type_dish ty)
{
setTitle(t);
setPrice(p);
setType(ty);
}
Dish::Dish(const Dish &obj)
{
title = obj.title;
price = obj.price;
type = obj.type;
}
Dish::Dish()
{
title = "Dish";
price = 0;
type = untyped;
}
Dish::~Dish()
{
}