//********************************************************* // Header file bowlingAlley.h for the bowlingAlley class. // Programming Project 4 // CS 241 Data Structures // Fall 2003 //********************************************************* using namespace std; #include #include "bowlingExceptions.h" #include "party.h" #include "IOExceptions.h" #ifndef BOWLINGALLEY_H #define BOWLINGALLEY_H const int NUM_LANES = 10; class bowlingAlley { public: // constructor bowlingAlley(); // Precondition: none // Postcondition: the new instance of the bowling has 0 groups bowling // querying functions bool isBowling(const party& group) const; // Precondition: group is an initialized party // Postcondition: returns true if group has been assigned a lane // returns false otherwise bool isEmpty() const; // Determines whether or not the bowlingAlley is empty. // Precondition: none // Postcondition: Returns true if the bowlingAlley is empty; // otherwise, returns false. int numberOfBowlingGroups() const; // Precondition: none // Postcondition: Returns the number of groups bowling in the // bowlingAlley. void displayGroups(ostream& out) const throw(outputException); // Displays the information of the groups in the bowlingAlley. // Precondition: out is a valid ostream ready to output // Postcondition: The information for each group is output to the // stream. No particular order can be guaranteed. A header line is // given before the first group. Each group is displayed on a // single line. See party::printOut for more information. If // the bowlingAlley is empty, no output is produced. // Exception: If out ever enters the fail state, an outputException // exception is thrown bool isASubsetOf(const bowlingAlley& B) const; // Determines if this instance is a subset of B // Precondition: none // Postcondition: returns true if the calling instance is a subset // of the parameters B. Returns false otherwise bool isEquivalentTo(const bowlingAlley& B) const; // Determines if this instance is equivalent to B // Precondition: none // Postcondition: returns true if the calling instance is equivalent // to the parameter B - order does not matter. Returns false // otherwise. // functions that modify the class void assignGroup(const party& newGroup) throw(bowlingAlleyFull, duplicateGroup); // Assigns newGroup a lane in the bowlingAlley. // Precondition: There are less than NUM_LANES groups already // assigned and newGroup has not already been assigned a lane // Postcondition: newGroup is assigned a lane // Exceptions: If a duplicate group is given, a duplicateGroup // exception is thrown. If the bowling all is full, a // bowlingAlleyFull exception is thrown. If both If both conditions // are true, duplicateGroup is thrown. void removeGroup(const party& group) throw(groupNotPresent); // removes group from the list of assigned groups. // Precondition: group is a party currently assigned a lane // Postcondition: group is removed from the list of assigned groups // Exception: If group is not currently assigned a lane, a // groupNotPresent exception is thrown. void getsACopyOf(const bowlingAlley& B); // copies the parties in B into this instance // Precondition: none // Postcondition: this instance contains an exact copy of B void getsUnionOf(const bowlingAlley& B1, const bowlingAlley& B2) throw(unionOverflow); // assigns this instance the union of B1 and B2 // Precondition: The union contains at most NUM_LANES parties // Postcondition: This instance contains the union of the two parameters. // Exception: If the union contains more than NUM_LANES parties, // this instance is not modified and a unionOverflow exception is // thrown. void getsIntersectionOf(const bowlingAlley& B1, const bowlingAlley& B2); // assigns this instance the intersection of B1 and B2 // Precondition: non // Postcondition: This instance contains the intersection of the two // parameters. private: int numberOfGroups; party lanes[NUM_LANES]; }; // end class bowlingAlley #endif