-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStereo.cpp
More file actions
80 lines (71 loc) · 1.49 KB
/
Stereo.cpp
File metadata and controls
80 lines (71 loc) · 1.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
//////////////////////////////////////////
// Workfile : Stereo.cpp
// Author : Pascal Lang
// Date : 09.01.2021
// Description : Implementation for concrete Device
//////////////////////////////////////////
#include "Stereo.h"
#include <string>
using namespace std;
//Custom C-Tor to create a stereo-device with cd drive
Stereo::Stereo(StereoCD::SPtr const& cd)
{
if (cd != nullptr)
{
mCD_Unit = cd;
}
}
void Stereo::Info(std::ostream& ost) const
{
ost << "Stereo is ";
//prints the current power state of the
//stereo system
switch(mState){
case TStatePower::eOn: ost << "on ";
break;
case TStatePower::eOff: ost << "off ";
break;
}
//if the member is different to nullpointer
//the stereo device has a cd drive
if (mCD_Unit != nullptr)
{
ost << "CD is ";
//prints the current state of the cd drive
switch (mCD_Unit->GetStateCD())
{
case TStateCD::eOpen: ost << "open" << endl;
break;
case TStateCD::eClosed: ost << "closed" << endl;
break;
}
}
else
{
ost << endl;
}
}
TStatePower Stereo::GetState() const
{
//returns the current powerstate
return mState;
}
void Stereo::SetState(TStatePower const& state)
{
//set the current powerstate to the given one
mState = state;
if (mCD_Unit != nullptr)
{
//if the stereo-device has a cd drive
//it will be truned on or off, depending on the
//given powerstate.
if (state == TStatePower::eOn)
{
mCD_Unit->SetStateCD(TStateCD::eOpen);
}
else
{
mCD_Unit->SetStateCD(TStateCD::eClosed);
}
}
}