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