-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCUltimateMachine
More file actions
39 lines (36 loc) · 952 Bytes
/
CUltimateMachine
File metadata and controls
39 lines (36 loc) · 952 Bytes
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
#include <iostream>
class CUltimateMachine{
public:
CUltimateMachine() : m_bState(false){
std:: cout << "CUltimateMachine constructor (ctor) called" << std::endl;
}
~CUltimateMachine(){
std::cout << "CUltimateMachine destructor (dtor) called" << std::endl;
}
void displayState(){
switch (m_bState){
case true:
std::cout << "Ultimate Machine is ON" << std::endl;
break;
case false:
std::cout << "Ultimate Machine is OFF" << std::endl;
break;
}
}
void turnOn(){
m_bState = true;
displayState();
if (true == m_bState){
m_bState = false;
}
displayState();
}
private:
bool m_bState;
};
int main(){
std::cout << "The Ultimate Machine simulation" << std::endl;
CUltimateMachine ultmach;
ultmach.displayState();
ultmach.turnOn();
}