sources:
BasicClass.cpp (550 bytes)
BasicClass.h (1.4k)
Date.cpp (3.8k)
Date.h (2.2k)
House.cpp (4.9k)
House.h (2.4k)
O2_1.cpp (619 bytes)
Room.cpp (2.3k)
Room.h (1.4k)


website:
more info here
studies/bauelemente/Softwarebauelemente-CodeO2-1/House.h
download file

  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 {
 30     // define new types for using the set
 31     typedef std::list<CRoom>            TSetOfRooms;
 32     typedef TSetOfRooms::iterator       TSetCursor;
 33     typedef TSetOfRooms::const_iterator TSetConstCursor;
 34
 35 public:
 36     // constructs a new house using its date of foundation (default: today)
 37     CHouse(const CDate& dtDateOfFoundation = CDate::GetToday());
 38
 39     // return class name
 40     static char* ClassnameOf() { return "CHouse"; }
 41
 42     // display the attributes
 43     friend ostream& operator<<(ostream& mystream, const CHouse& house);
 44    
 45     // compare two houses
 46     bool operator==(const CHouse& house) const;
 47     virtual bool Equal(const CHouse* house) const;
 48     virtual bool EqualValue(const CHouse* house) const;
 49
 50     // copy one house to another one
 51     CHouse&  operator=(const CHouse &house);
 52     virtual bool Copy(const CHouse* house);
 53
 54     // return date of foundation
 55     CDate GetDateOfFoundation() const;
 56     // return number of stored rooms
 57     int Card() const;
 58
 59     // insert a new room into the set, TRUE if successful
 60     // will fail if room already exists
 61     bool Insert(const CRoom& room);
 62     // return first stored room, TRUE if successful
 63     bool GetFirst(CRoom& room);
 64     // return next room, TRUE if successful
 65     bool GetNext(CRoom& room);
 66     // look for a room and set cursor, TRUE if successful
 67     bool Find(const CRoom& room);
 68     // return the room the cursor points to, TRUE if successful
 69     bool GetCurrent(CRoom& room) const;
 70     // erase current room, TRUE if successful
 71     bool Scratch();
 72
 73 protected:
 74     // used to perform proper display in derived classes
 75     virtual ostream& OutStream(ostream& mystream, bool bDebug=false) const;
 76
 77 private:
 78     CDate m_dtDateOfFoundation;
 79
 80     TSetOfRooms m_Set;
 81     TSetCursor  m_itCursor;
 82 };
 83
 84 #endif // !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
 85