1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente I, Aufgabe M6.1
3 //
4 // author: Stephan Brumme
5 // last changes: November 23, 2000
6
7
8 // import cout to display some data
9 #include <iostream>
10 #include "MRoom.h"
11
12 // open std namespace
13 using namespace std;
14
15
16
17 // define the namespace Room
18
19 // Initializes the TRoom structure
20 void MRoom::Init(TRoom &roo, Ordinal nor, Ordinal ar)
21 {
22 roo.NumberOfRooms = nor;
23 roo.Area = ar;
24 }
25
26
27 // Compares two exemplars
28 // returns "true" if attributes of both are equal; "false" otherwise
29 Boolean MRoom::EqualValue(TRoom roo1, TRoom roo2)
30 {
31 return ((roo1.Area == roo2.Area) &&
32 (roo1.NumberOfRooms = roo2.NumberOfRooms));
33 }
34
35
36 // Copies the attributes of roo2
37 // returns "true" if successful, "false" if no memory allocated
38 Boolean MRoom::Copy(TRoom& roo1, TRoom roo2)
39 {
40 if (EqualValue(roo1, roo2))
41 return false;
42
43 roo1.Area = roo2.Area;
44 roo1.NumberOfRooms = roo2.NumberOfRooms;
45 return true;
46 }
47
48
49 // Returns the NumberOfRooms attribute
50 Ordinal MRoom::GetNumberOfRooms(TRoom roo)
51 {
52 return roo.NumberOfRooms;
53 }
54
55
56 // Sets the NumberOfRooms attribute
57 void MRoom::SetNumberOfRooms(TRoom &roo, Ordinal nor)
58 {
59 roo.NumberOfRooms = nor;
60 }
61
62
63 // Returns the Area attribute
64 Ordinal MRoom::GetArea(TRoom roo)
65 {
66 return roo.Area;
67 }
68
69
70 // Displays the attributes
71 void MRoom::Show(TRoom roo)
72 {
73 cout<<"Es sind "<<roo.NumberOfRooms<<" Raeume mit einer Flaeche von "<<roo.Area
<<"."<<endl;
74 }
75
76 // end of namespace Room
77
78