sources:
M06_2.cpp (391 bytes)
MDate.cpp (1.8k)
MDate.h (956 bytes)
MHouse.cpp (4.9k)
MHouse.h (1.9k)
MRoom.cpp (1.5k)
MRoom.h (1.1k)
PrimitiveTypes.h (421 bytes)


website:
more info here
studies/bauelemente/Softwarebauelemente-CodeM6-2/MHouse.h
download file

  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 {
 21     // open namespaces MRoom and MDate
 22     using namespace MRoom;
 23     using namespace MDate;
 24
 25     // max. number of rooms in a house
 26     const Ordinal ROOMS = 20;
 27
 28     // array of pointers containing the housems
 29     typedef TRoom TArrayOfRooms[ROOMS];
 30
 31     // data struct THouse for a single house
 32     typedef struct
 33     {
 34         TDate   DateOfFoundation;
 35         Ordinal Count;
 36         Ordinal Cursor;
 37         TArrayOfRooms PSet;
 38     } THouse;
 39
 40
 41     // initializes the THouse structure
 42     void Init(THouse &house);
 43
 44     // compares two exemplars
 45     // returns "true" if attributes of both are equal; "false" otherwise
 46     Boolean EqualValue(const THouse& house1, const THouse& house2);
 47
 48     // copies the attributes of house2
 49     // returns "true" if successful, "false" if no memory allocated
 50     Boolean Copy(THouse& house1, const THouse& house2);
 51
 52     // retrieve date of foundation
 53     TDate GetDateOfFoundation(const THouse& house);
 54
 55     // get number of rooms
 56     Ordinal Card(const THouse& house);
 57
 58     // add a new room to a house
 59     Boolean Insert(THouse& house, const TRoom& room);
 60
 61     // returns the first room of a house
 62     Boolean GetFirst(THouse& house, TRoom& room);
 63
 64     // returns the last room of a house
 65     Boolean GetNext(THouse& house, TRoom& room);
 66
 67     // looks for a given room and sets cursor, if possible
 68     Boolean Find(THouse& house, const TRoom& room);
 69
 70     // returns the room the cursors points to
 71     Boolean GetCurrent(const THouse& house, TRoom& room);
 72
 73     // deletes the room the cursor points to
 74     Boolean Scratch(THouse& house);
 75
 76     // displays the attributes
 77     void Show(THouse house);
 78 };
 79
 80 #endif
 81