1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente I, Aufgabe M6.2.
3 //
4 // author: Stephan Brumme
5 // last changes: December 29, 2000
6
7 #ifndef __MHOUSE_H__
8 #define __MHOUSE_H__
9
10 // we need the CEDL-types Ordinal, ...
11 #include "PrimitiveTypes.h"
12
13 // import MDate
14 #include "MDate.h"
15 // import MRoom
16 #include "MRoom.h"
17
18
19 namespace MHouse
{
20 // open namespaces MRoom and MDate
21 using namespace MRoom;
22 using namespace MDate;
23
24 // max. number of rooms in a house
25 const Ordinal ROOMS = 20;
26
27 // array of pointers containing the housems
28 typedef TRoom TArrayOfRooms[ROOMS];
29
30 // data struct THouse for a single house
31 typedef struct
32 {
33 TDate DateOfFoundation;
34 Ordinal Count;
35 Ordinal Cursor;
36 TArrayOfRooms PSet;
37 } THouse;
38
39
40 // initializes the THouse structure
41 void Init(THouse &house);
42
43 // compares two exemplars
44 // returns "true" if attributes of both are equal; "false" otherwise
45 Boolean EqualValue(const THouse& house1, const THouse& house2);
46
47 // copies the attributes of house2
48 // returns "true" if successful, "false" if no memory allocated
49 Boolean Copy(THouse& house1, const THouse& house2);
50
51 // retrieve date of foundation
52 TDate GetDateOfFoundation(const THouse& house);
53
54 // get number of rooms
55 Ordinal Card(const THouse& house);
56
57 // add a new room to a house
58 Boolean Insert(THouse& house, const TRoom& room);
59
60 // returns the first room of a house
61 Boolean GetFirst(THouse& house, TRoom& room);
62
63 // returns the last room of a house
64 Boolean GetNext(THouse& house, TRoom& room);
65
66 // looks for a given room and sets cursor, if possible
67 Boolean Find(THouse& house, const TRoom& room);
68
69 // returns the room the cursors points to
70 Boolean GetCurrent(const THouse& house, TRoom& room);
71
72 // deletes the room the cursor points to
73 Boolean Scratch(THouse& house);
74
75 // displays the attributes
76 void Show(THouse house);
77 };
78
79 #endif
80