1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente I, Aufgabe O1.1
3 //
4 // author: Stephan Brumme
5 // last changes: January 13, 2001
6
7 #include "Room.h"
8 #include <iostream>
9
10
11 // compare the room with another one
12 Boolean CRoom::operator==(const CRoom& room) const
13 {
14 return ((room.m_nArea == m_nArea) &&
15 (room.m_nNumberOfRoom == m_nNumberOfRoom));
16 }
17
18
19 // compare the room with another one
20 // routes call down to "==" operator
21 Boolean CRoom::EqualValue(const CRoom& room) const
22 {
23 return (operator==(room));
24 }
25
26
27
28 // copy one room to another one
29 // prevents user from copying an object to itself
30 CRoom& CRoom::operator=(const CRoom& room)
31 {
32 // cannot copy an object to itself
33 if (this != &room)
34 {
35 // copy all variables
36 m_nArea = room.m_nArea;
37 m_nNumberOfRoom = room.m_nNumberOfRoom;
38 }
39
40 return *this;
41 }
42
43
44 // copy one room to another one
45 // prevents user from copying an object to itself
46 // calls "=" operator internally
47 Boolean CRoom::Copy(const CRoom &room)
48 {
49 // cannot copy an object to itself
50 if (this == &room)
51 return false;
52
53 // use "=" operator
54 operator=(room);
55
56 return true;
57 }
58
59
60 // retrieve the private value of m_nNumberOfRoom
61 Ordinal CRoom::GetNumberOfRoom() const
62 {
63 return m_nNumberOfRoom;
64 }
65
66
67 // change private m_nNumberOfRoom
68 void CRoom::SetNumberOfRoom(const Ordinal nNumberOfRoom)
69 {
70 m_nNumberOfRoom = nNumberOfRoom;
71 }
72
73
74 // retrieve the private value of m_nArea
75 Ordinal CRoom::GetArea() const
76 {
77 return m_nArea;
78 }
79
80
81 // display the attributes
82 // only for internal purposes !
83 void CRoom::Show() const
84 {
85 // open namespace
86 using namespace std;
87
88 // display the crap using default output
89 cout << "The current room has the room number "<<GetNumberOfRoom()
90 <<" and covers "<<GetArea()<<" acres !"<<endl;
91 }
92