-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome_Appliance.cpp
More file actions
162 lines (144 loc) · 3.77 KB
/
Home_Appliance.cpp
File metadata and controls
162 lines (144 loc) · 3.77 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
/********************************************************************************************
* @file Home_Appliance.c
*
* @brief Home_Appliance driver as a base class
*
* @details Home_Appliance is a base class that includes the common properties of
* identification code, height, length, width and energy consumption class
* as data members and get and set functions associated with these data members,
* in addition to these, a print function that prints all the parameters together
* and a control function that detects any number out of characters.
*
* @author Aysenur Bolat
*
* @version V1.0
*
* @date 28. December 2018
*********************************************************************************************/
#include "Home_Appliance.h"
using namespace std;
Home_Appliance::Home_Appliance(string ID, int varHeight, int varLength, int varWidth,string energyClass )
{
setIdentificationCode( ID ) ;
setHeight( varHeight );
setLength( varLength );
setWidth( varWidth );
setEnergyConsumptionClass( energyClass );
}
/**
* @brief Set the identification code of home appliance
* @param Identification code that consists of digits and a letter
* @retval void
*/
void Home_Appliance::setIdentificationCode( string ID)
{
identificationCode = ID;
}
/**
* @brief Set the height of home appliance
* @param Height in centimeters
* @retval void
*/
void Home_Appliance::setHeight( int varHeight )
{
height = varHeight;
}
/**
* @brief Set the length of home appliance
* @param Length in centimeters
* @retval void
*/
void Home_Appliance::setLength( int varLength)
{
length = varLength;
}
/**
* @brief Set the width of home appliance
* @param Width in centimeters
* @retval void
*/
void Home_Appliance::setWidth( int varWidth )
{
width = varWidth;
}
/**
* @brief Set the energy consumption class of home appliance
* @param Energy consumption class that consists of letter(s)
* @retval void
*/
void Home_Appliance::setEnergyConsumptionClass( string energyClass)
{
energyConsumptionClass = energyClass;
}
/**
* @brief Get the identification code of home appliance
* @param void
* @retval Identification code as string
*/
string Home_Appliance::getIdentificationCode() const
{
return identificationCode;
}
/**
* @brief Get the height of home appliance
* @param void
* @retval Height of a home appliance in centimeters
*/
int Home_Appliance::getHeight() const
{
return height;
}
/**
* @brief Get the length of home appliance
* @param void
* @retval Length of a home appliance in centimeters
*/
int Home_Appliance::getLength() const
{
return length;
}
/**
* @brief Get the width of home appliance
* @param void
* @retval Width of a home appliance in centimeters
*/
int Home_Appliance::getWidth() const
{
return width;
}
/**
* @brief Get energy consumption class of home appliance
* @param void
* @retval Energy consumption class consists of letter(s)
*/
string Home_Appliance::getEnergyConsumptionClass() const
{
return energyConsumptionClass;
}
/**
* @brief Print the all common properties of home appliance
* @param void
* @retval void
*/
void Home_Appliance::printProperties() const
{
cout << this->getIdentificationCode() << " " << this->getHeight() << " " << this->getLength()
<< " " << this->getWidth() << " " << this->getEnergyConsumptionClass();
}
/**
* @brief Detect if the given string consists of only letters or not.
* @param void
* @retval Value true if the string has only letters
*/
bool Home_Appliance::IsLetter(string input) const
{
for( unsigned int i = 0; i < input.size(); i++)
{
int upperCaseChar = toupper( input[i] );
if( upperCaseChar < 'A' || upperCaseChar > 'Z')
{
return false;
}
}
return true;
}