1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente I, Aufgabe O1.3
3 //
4 // author: Stephan Brumme
5 // last changes: January 15, 2001
6
7 #include "CashOffice.h"
8 #include <iostream>
9
10
11 // compare the CashOffice with another one
12 Boolean CCashOffice::operator==(const CCashOffice& cashOffice) const
13 {
14 // use the CRoom compare function
15 return (CRoom::operator==(cashOffice) &&
16 m_nNumberOfCounter == cashOffice.m_nNumberOfCounter);
17 }
18
19
20 // compare the CashOffice with another one
21 // routes call down to "==" operator
22 Boolean CCashOffice::EqualValue(const CCashOffice& cashOffice) const
23 {
24 return (operator==(cashOffice));
25 }
26
27
28 // copy one CashOffice to another one
29 // prevents user from copying an object to itself
30 CCashOffice& CCashOffice::operator=(const CCashOffice& cashOffice)
31 {
32 // cannot copy an object to itself
33 if (this != &cashOffice)
34 {
35 // copy all variables
36 // first copy the attributes of CRoom
37 CRoom::operator=(cashOffice);
38 // and now our new ones of CCashOffice
39 m_nNumberOfCounter = cashOffice.m_nNumberOfCounter;
40 }
41
42 return *this;
43 }
44
45
46 // copy one CashOffice to another one
47 // prevents user from copying an object to itself
48 // calls "=" operator internally
49 Boolean CCashOffice::Copy(const CCashOffice &cashOffice)
50 {
51 // cannot copy an object to itself
52 if (this == &cashOffice)
53 return false;
54
55 // use "=" operator
56 operator=(cashOffice);
57
58 return true;
59 }
60
61
62 // retrieve the private value of m_nNumberOfCounter
63 Ordinal CCashOffice::GetNumberOfCounter() const
64 {
65 return m_nNumberOfCounter;
66 }
67
68
69 // change private m_nNumberOfCounter
70 void CCashOffice::SetNumberOfCounter(const Ordinal nNumberOfCounter)
71 {
72 m_nNumberOfCounter = nNumberOfCounter;
73 }
74
75
76 // retrieve the private value of CRoom::m_nNumberOfCashOffice
77 Ordinal CCashOffice::GetNumberOfCashOffice() const
78 {
79 return CRoom::GetNumberOfRoom();
80 }
81
82
83 // change private CRoom::m_nNumberOfCashOffice
84 void CCashOffice::SetNumberOfCashOffice(const Ordinal nNumberOfCashOffice)
85 {
86 CRoom::SetNumberOfRoom(nNumberOfCashOffice);
87 }
88
89
90 // deliver CRoom::m_nArea
91 Ordinal CCashOffice::GetAreaOfCashOffice() const
92 {
93 return CRoom::GetArea();
94 }
95
96
97 // display the attributes
98 // only for internal purposes !
99 void CCashOffice::Show() const
100 {
101 // open namespace
102 using namespace std;
103
104 // display the crap using default output
105
106 // the CRoom member variables
107 CRoom::Show();
108 // and the CCashOffice ones
109 cout << "The number of counter is "<<GetNumberOfCounter()<<"."<<endl;
110 }
111