-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDishwasher.cpp
More file actions
254 lines (208 loc) · 7.49 KB
/
Dishwasher.cpp
File metadata and controls
254 lines (208 loc) · 7.49 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
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
246
247
248
249
250
251
252
253
254
/*******************************************************************************************************
* @file Dishwasher.c
*
* @brief Dishwasher driver as a derived class of home appliance
*
* @details Dishwasher is a derived class of a Home_Appliance and it includes the properties
* such as water consumption value, number of programs of dishwasher, capacity, number of racks
* number of dishwashers in the inventory and the engine properties as a dishwasher engine.
* Composition of Engine class to Dishwasher class is used due to the fact that a dishwasher has a engine property.
*
* @author Aysenur Bolat
*
* @version V1.0
*
* @date 28. December 2018
********************************************************************************************************/
#include "Dishwasher.h"
using namespace std;
/**
* @brief Constructor for dishwasher class
*
* @details From the first parameter to the water consumption parameter, they all belong to the base class Home_Appliance.
* Dishwasher is inherited from the Home Appliance because dishwasher is a home appliance type.
* For this reason, in the constructor of dishwasher, Home_Appliance constructor is called for the first five
* parameters. In addition, dishwasher has a dishwasher engine and the engine class is added as a composition
* to dishwasher class. According to the composition basics, referance value in type of Engine is used as a
* parameter in the dishwasher constructor. Parameter d_engine value is stored in the dishwasherEngine
* variable which is decleared in the Dishwasher.h file. This value assignment is done with the
* member initializer list. At the beginning, the default values written in the main file are sent to the
* data members with set functions. This is necessary for creating the default valued- objects and then,
* the user is able to give desired values to these variables with directly using constructor. That is why
* addition set functions and input - output operations beside the member initializer list and the first
* four set functions.
*
* @param Identification code, height, length, width values, energy consumption class, water consumption in liters,
* number of programs that dishwasher has, capacity of dishwasher, number of racks, engine properties as a
* referance of type Engine, and a number of dishwashers in the inventory.
*
*/
Dishwasher::Dishwasher(string ID, int varHeight,int varLength,int varWidth,string energyClass,
int consumption,int numPrograms, int varCapacity, int numRacks, Engine &d_engine, int numOfProd)
: Home_Appliance( ID, varHeight, varLength, varWidth, energyClass),
dishwasherEngine(d_engine)
{
setWaterConsumption(consumption);
setNumberOfCleaningPrograms(numPrograms),
setCapacityOfDishes(varCapacity);
setNumberOfRacks(numRacks);
int waterSprayCap;
double d_power;
int rotation;
cout << "Enter the dishwasher properties respectively." << endl;
cout << "\nID: " ;
cin >> ID;
setIdentificationCode(ID);
cout << "\nHeight in Centimeters: ";
cin >> varHeight;
setHeight(varHeight);
cout << "\nLength in Centimeters: ";
cin >> varLength;
setLength(varLength);
cout << "\nWidth in Centimeters: ";
cin >> varWidth;
setWidth(varWidth);
cout<< "\nEnergy Consumption Class: " ;
cin >> energyClass;
if( Home_Appliance::IsLetter(energyClass) )
setEnergyConsumptionClass(energyClass);
else
throw invalid_argument("Energy consumption class must consist of letter(s).");
cout << "\nWater Consumption in Liters: ";
cin >> consumption;
setWaterConsumption(consumption);
cout <<"\nNumber of Cleaning Programs: ";
cin >> numPrograms;
setNumberOfCleaningPrograms(numPrograms);
cout << "\nCapacity as Number of Dishes: ";
cin >> varCapacity;
setCapacityOfDishes(varCapacity);
cout << "\nNumber of Racks: ";
cin >> numRacks;
setNumberOfRacks(numRacks);
cout << "\nPower of Dishwasher Engine: ";
cin >> d_power;
this->dishwasherEngine.setPower(d_power);
cout << "\nRotation of Dishwasher Engine: ";
cin >> rotation;
this->dishwasherEngine.setNumberOfRotations(rotation);
cout << "\nWater Spray Capacity of Dishwasher Engine: ";
cin >> waterSprayCap;
this->dishwasherEngine.setMaxFeatureCap(waterSprayCap,2);
cout <<"\nEnter number of products:";
cin>>numOfProd;
this->setNumberOfProduct(numOfProd);
}
Dishwasher::~Dishwasher()
{
}
/**
* @brief Set water consumption value of dishwasher in liters
* @param Water consumption value in type of integer
* @retval void
*/
void Dishwasher::setWaterConsumption( int consumption )
{
waterConsumption = consumption;
}
/**
* @brief Set number of cleaning programs of dishwasher
* @param Number of cleaning programs in type of integer
* @retval void
*/
void Dishwasher::setNumberOfCleaningPrograms( int numPrograms )
{
numberOfCleaningPrograms = numPrograms;
}
/**
* @brief Set capacity of dishes of dishwasher
* @param Capacity of dishes in type of integer
* @retval void
*/
void Dishwasher::setCapacityOfDishes( int varCapacity)
{
capacityOfDishes = varCapacity;
}
/**
* @brief Set number of racks of dishwasher
* @param Number of racks in type of integer
* @retval void
*/
void Dishwasher::setNumberOfRacks( int numRacks)
{
numberOfRacks = numRacks;
}
/**
* @brief Set number of dishwashers in the inventory
* @param Number of dishwashers in type of integer
* @retval void
*/
void Dishwasher::setNumberOfProduct(int numOfProd)
{
this->numberOfProduct = numOfProd;
}
/**
* @brief Get water consumption in liters
* @param void
* @retval Water consumption in type of integer
*/
int Dishwasher::getWaterConsumption() const
{
return waterConsumption;
}
/**
* @brief Get number of cleaning programs of dishwasher
* @param void
* @retval number of cleaning programs in type of integer
*/
int Dishwasher::getNumberOfCleaningPrograms() const
{
return numberOfCleaningPrograms;
}
/**
* @brief Get capacity of dishes of dishwasher
* @param void
* @retval capacity of dishes in type of integer
*/
int Dishwasher::getCapacityOfDishes() const
{
return capacityOfDishes;
}
/**
* @brief Get number of racks of dishwasher
* @param void
* @retval Number of racks in type of integer
*/
int Dishwasher::getNumberOfRacks() const
{
return numberOfRacks;
}
/**
* @brief Get number of dishwashers
* @param void
* @retval Number of dishwashers in type of integer
*/
int Dishwasher::getNumberOfProduct()const
{
return this->numberOfProduct;
}
/**
* @brief Print all the associated properties of dishwasher
* @details The common properties that are inherited from the base class Home_Appliance
* are printed with the print function that belongs to the same base class
* Home_Appliance. Dishwasher's own properties are printed with its own print
* function. Engine properties are printed with the function belongs to the Engine
* class. The decleared dishwasherEngine variable of type Engine is used to
* access to the Engine's print and get functions.
* @param void
* @retval void
*/
void Dishwasher::printProperties() const
{
Home_Appliance::printProperties();
cout << " " << this->getWaterConsumption() << " " << this->getNumberOfCleaningPrograms() << " "
<< this->getCapacityOfDishes() << " " << this->getNumberOfRacks();
dishwasherEngine.printEngine();
cout << " " << dishwasherEngine.getMaxWaterSprayCapacity();
cout <<" " <<this->getNumberOfProduct();
}