sources:
CashOffice.cpp (2.5k)
CashOffice.h (1.6k)
O1_3.cpp (1.2k)
PrimitiveTypes.h (421 bytes)
Room.cpp (1.8k)
Room.h (1.4k)


website:
more info here
studies/bauelemente/Softwarebauelemente-CodeO1-3/CashOffice.cpp
download file

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