1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente I, Aufgabe O1.2
3 //
4 // author: Stephan Brumme
5 // last changes: January 14, 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 // display the attributes
77 // only for internal purposes !
78 void CCashOffice::Show() const
79 {
80 // open namespace
81 using namespace std;
82
83 // display the crap using default output
84
85 // the CRoom member variables
86 CRoom::Show();
87 // and the CCashOffice ones
88 cout << "The number of counter is "<<GetNumberOfCounter()<<"."<<endl;
89 }
90