hotel-contract

hotel-contract - repair_rooms : LIST[ROOMS] -- List of all...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
exercise-in-contracts Page 1 You are given the following defined class ROOM with the only features you need for this problem. class ROOM feature {ANY} status : STATUS -- One of reserved , unreserved , occupied , repair guest : GUEST -- Only for HOTEL void unless occupied or reserved . end Write require, ensure and class invariant assertions for the following methods of a class HOTEL that represents rooms and guests at a hotel. The minimum size of a hotel is 100 rooms. Write your assertions in as formal a mathematical notation as possible. Your assertions do not have to be executable. class HOTEL create make feature avail_rooms : LIST[ROOMS] -- List of all the rooms not under repair -- available for use
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: repair_rooms : LIST[ROOMS] -- List of all the rooms under repair capacity : INTEGER -- Number of rooms in the hotel make (size : INTEGER) -- Build a new hotel with size rooms where all rooms are available. require ensure vacancy : BOOLEAN -- Returns true if and only if there is an unreserved room. require ensure unreserved_check_in (guest : GUEST) -- The guest has not made a reservation. Puts the guest into an unreserved room. require ensure remove_room_for_repair (room : ROOM) -- Moves an unoccupied room from the available list to the repair list. require ensure vacancy_count : INTEGER -- Returns the number of unreserved rooms. require ensure invariant end...
View Full Document

Ask a homework question - tutors are online