sources:
BasicClass.h (1.4k)
C1_1.cpp (604 bytes)
CashOffice.cpp (3.8k)
CashOffice.h (1.8k)
Date.cpp (6.0k)
Date.h (2.9k)
Exception.cpp (2.5k)
Exception.h (1.4k)
House.cpp (7.5k)
House.h (2.7k)
Room.cpp (3.0k)
Room.h (1.6k)


binaries:
Release/C1_1.exe (140.0k)


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

  1 ///////////////////////////////////////////////////////////
  2 // Softwarebauelemente II, Aufgabe C1.1
  3 //
  4 // author: Stephan Brumme
  5 // last changes: July 3, 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 <set>
 18
 19 // CRoom used as member variable
 20 #include "Room.h"
 21 // CDate used as member variable
 22 #include "Date.h"
 23 // template used to compare two objects
 24 #include "MyLess.tli"
 25
 26
 27 // disable compiler warning (too long names)
 28 #pragma warning (disable: 4786)
 29
 30
 31 class CHouse : public CBasicClass
 32 {
 33     // define new types for using the set
 34 // typedef set<CRoom> TSetOfRooms;
 35     typedef set<CRoom, MyLess<CRoom> >  TSetOfRooms;
 36     typedef TSetOfRooms::iterator       TSetCursor;
 37     typedef TSetOfRooms::const_iterator TSetConstCursor;
 38
 39     // my own iterator
 40     typedef void (*TIteratorFunc) (CRoom*);
 41
 42 public:
 43     // constructs a new house using its date of foundation (default: today)
 44     CHouse();
 45     CHouse(const CHouse& house);
 46     CHouse(const CDate& dtDateOfFoundation);
 47
 48     // return class name
 49     virtual string ClassnameOf() const { return "CHouse"; }
 50
 51     // display the attributes
 52     virtual string Show() const;
 53     // only for internal purposes !
 54     virtual string ShowDebug() const;
 55    
 56     // validate a house
 57     virtual bool ClassInvariant() const;
 58
 59     // compare two houses
 60     bool operator==(const CHouse& house) const;
 61     virtual bool EqualValue(const CBasicClass* pClass) const;
 62
 63     // copy one house to another one
 64     CHouse&  operator=(const CHouse &house);
 65     virtual bool Copy(const CBasicClass* pClass);
 66
 67     // return date of foundation
 68     CDate GetDateOfFoundation() const;
 69     // return number of stored rooms
 70     int Card() const;
 71
 72     // insert a new room into the set, TRUE if successful
 73     // will fail if room already exists
 74     bool Insert(const CRoom& room);
 75     // return first stored room, TRUE if successful
 76     bool GetFirst(CRoom& room);
 77     // return next room, TRUE if successful
 78     bool GetNext(CRoom& room);
 79     // look for a room and set cursor, TRUE if successful
 80     bool Find(const CRoom& room);
 81     // return the room the cursor points to, TRUE if successful
 82     bool GetCurrent(CRoom& room) const;
 83     // erase current room, TRUE if successful
 84     bool Scratch();
 85
 86     // iterate through the set
 87     void ForEachDo(const TIteratorFunc iterator);
 88     // show elements by calling ForEachDo
 89     string ShowUsingForEachDo() const;
 90
 91 private:
 92     CDate m_dtDateOfFoundation;
 93
 94     TSetOfRooms m_Set;
 95     TSetCursor  m_itCursor;
 96 };
 97
 98 #endif // !defined(AFX_HOUSE_H__A8EA7860_08E1_11D5_9BB7_A8652B9FDD20__INCLUDED_)
 99