1 ///////////////////////////////////////////////////////////
2 // Softwarebauelemente II, Aufgabe O2.1
3 //
4 // author: Stephan Brumme
5 // last changes: February 26, 2001
6
7 #if !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
8 #define AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_
9
10
11 #if _MSC_VER > 1000
12 #pragma once
13 #endif // _MSC_VER > 1000
14
15
16 // STL's list container
17 #include <list>
18
19 // CRoom used as member variable
20 #include "Room.h"
21 // CDate used as member variable
22 #include "Date.h"
23 // for basic class behaviour
24 #include "BasicClass.h"
25
26
27
28 class CHouse : public CBasicClass
{
29 // define new types for using the set
30 typedef std::list<CRoom> TSetOfRooms;
31 typedef TSetOfRooms::iterator TSetCursor;
32 typedef TSetOfRooms::const_iterator TSetConstCursor;
33
34 public:
35 // constructs a new house using its date of foundation (default: today)
36 CHouse(const CDate& dtDateOfFoundation = CDate::GetToday());
37
38 // return class name
39 static char* ClassnameOf() { return "CHouse"; }
40
41 // display the attributes
42 friend ostream& operator<<(ostream& mystream, const CHouse& house);
43
44 // compare two houses
45 bool operator==(const CHouse& house) const;
46 virtual bool Equal(const CHouse* house) const;
47 virtual bool EqualValue(const CHouse* house) const;
48
49 // copy one house to another one
50 CHouse& operator=(const CHouse &house);
51 virtual bool Copy(const CHouse* house);
52
53 // return date of foundation
54 CDate GetDateOfFoundation() const;
55 // return number of stored rooms
56 int Card() const;
57
58 // insert a new room into the set, TRUE if successful
59 // will fail if room already exists
60 bool Insert(const CRoom& room);
61 // return first stored room, TRUE if successful
62 bool GetFirst(CRoom& room);
63 // return next room, TRUE if successful
64 bool GetNext(CRoom& room);
65 // look for a room and set cursor, TRUE if successful
66 bool Find(const CRoom& room);
67 // return the room the cursor points to, TRUE if successful
68 bool GetCurrent(CRoom& room) const;
69 // erase current room, TRUE if successful
70 bool Scratch();
71
72 protected:
73 // used to perform proper display in derived classes
74 virtual ostream& OutStream(ostream& mystream, bool bDebug=false) const;
75
76 private:
77 CDate m_dtDateOfFoundation;
78
79 TSetOfRooms m_Set;
80 TSetCursor m_itCursor;
81 };
82
83 #endif // !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
84
85