sources:
BasicClass.h (1.4k)
CashOffice.cpp (3.7k)
CashOffice.h (1.7k)
Date.cpp (6.1k)
Date.h (2.9k)
House.cpp (6.1k)
House.h (2.3k)
O3_1.cpp (737 bytes)
Room.cpp (2.9k)
Room.h (1.5k)


binaries:
Release/O3_1.exe (124.0k)


website:
more info here
studies/bauelemente/Softwarebauelemente-CodeO3-1/CashOffice.cpp
download file

  1 ///////////////////////////////////////////////////////////
  2 // Softwarebauelemente II, Aufgabe O3.1
  3 //
  4 // author: Stephan Brumme
  5 // last changes: May 15, 2001
  6
  7 #include "CashOffice.h"
  8
  9
 10 // default constructor
 11 CCashOffice::CCashOffice() : CRoom()
 12 {
 13     m_nNumberOfCounter = 0;
 14 }
 15
 16 // copy constructor
 17 CCashOffice::CCashOffice(const CCashOffice& cashOffice)
 18 {
 19     operator=(cashOffice);
 20 }
 21
 22 CCashOffice::CCashOffice(int nNumberOfRoom, int nArea, int nNumberOfCounter)
 23     : CRoom(nNumberOfRoom, nArea)
 24 {
 25     m_nNumberOfCounter = nNumberOfCounter;
 26 }
 27    
 28
 29 // display the attributes
 30 string CCashOffice::Show() const
 31 {
 32     ostringstream strOutput;
 33
 34     strOutput << CRoom::Show() << " Counter no. "
 35               << m_nNumberOfCounter << "." << endl;
 36
 37     return strOutput.str();
 38 }
 39
 40
 41 // display the attributes
 42 // only for internal purposes !
 43 string CCashOffice::ShowDebug() const
 44 {
 45     ostringstream strOutput;
 46
 47     strOutput << CRoom::ShowDebug()
 48               << "DEBUG info for 'CCashOffice'" << endl
 49               << " m_nNumberOfCounter = " << m_nNumberOfCounter << endl;
 50
 51     return strOutput.str();
 52 }
 53
 54
 55 // verify invariance
 56 bool CCashOffice::ClassInvariant() const
 57 {
 58     // only positive numbers allowed
 59     return (CRoom::ClassInvariant() &&
 60             m_nNumberOfCounter > 0  && m_nNumberOfCounter <= MAXCOUNTER)
;
 61 }
 62
 63
 64 // copy one CashOffice to another one
 65 CCashOffice& CCashOffice::operator=(const CCashOffice& cashOffice)
 66 {
 67     // copy all variables
 68     // first copy the attributes of CRoom
 69     CRoom::operator=(cashOffice);
 70     // and now our new ones of CCashOffice
 71     m_nNumberOfCounter = cashOffice.m_nNumberOfCounter;
 72
 73     return *this;
 74 }
 75
 76
 77 // virtual, see operator=
 78 bool CCashOffice::Copy(const CBasicClass* pClass)
 79 {
 80     // cast to CCashOffice
 81     CBasicClass *basic;
 82     CCashOffice *cashOffice;
 83     basic = const_cast<CBasicClass*>(pClass);
 84     cashOffice = dynamic_cast<CCashOffice*>(basic);
 85
 86     // invalid class (is NULL when pClass is not a CCashOffice)
 87     if (cashOffice == NULL || cashOffice == this)
 88         return false;
 89
 90     // use non virtual reference based copy
 91     // return value isn't needed
 92     operator=(*cashOffice);
 93
 94     // we're done
 95     return true;
 96 }
 97
 98
 99 // compare the CashOffice with another one
100 bool CCashOffice::operator==(const CCashOffice& cashOffice) const
101 {
102     // use the CRoom compare function
103     return (CRoom::operator==(cashOffice) &&
104             m_nNumberOfCounter == cashOffice.m_nNumberOfCounter)
;
105 }
106
107
108 // compare the CashOffice with another one
109 // routes call down to "==" operator
110 bool CCashOffice::EqualValue(const CBasicClass* pClass) const
111 {
112     // cast to CCashOffice
113     CBasicClass *basic;
114     CCashOffice *cashOffice;
115     basic = const_cast<CBasicClass*>(pClass);
116     cashOffice = dynamic_cast<CCashOffice*>(basic);
117
118     // invalid class (is NULL when pClass is not a CCashOffice)
119     if (cashOffice == NULL || cashOffice == this)
120         return false;
121
122     // use non virtual reference based copy
123     return operator==(*cashOffice);
124 }
125
126
127 // retrieve the private value of m_nNumberOfCounter
128 int CCashOffice::GetNumberOfCounter() const
129 {
130     return m_nNumberOfCounter;
131 }
132
133
134 // change private m_nNumberOfCounter
135 void CCashOffice::SetNumberOfCounter(const int nNumberOfCounter)
136 {
137     m_nNumberOfCounter = nNumberOfCounter;
138 }
139
140
141 // retrieve the private value of CRoom::m_nNumberOfCashOffice
142 int CCashOffice::GetNumberOfCashOffice() const
143 {
144     return CRoom::GetNumberOfRoom();
145 }
146
147
148 // change private CRoom::m_nNumberOfCashOffice
149 void CCashOffice::SetNumberOfCashOffice(const int nNumberOfCashOffice)
150 {
151     CRoom::SetNumberOfRoom(nNumberOfCashOffice);
152 }
153
154
155 // deliver CRoom::m_nArea
156 int CCashOffice::GetAreaOfCashOffice() const
157 {
158     return CRoom::GetArea();
159 }
160
161
162