August 2000 QUESTION 4 Total Marks: 15 Marks |
Click here to access
other questions
Click to access |
You are required to implement a reservation
system for meeting rooms. A room has a name, for example Meeting
Room, and it has a number of slots. A slot is a time period
in which the room may be booked. A slot has a time, and a day. The
time can be any one of 9 am, 10 am, etc all the way to 4 pm, and a
day can be any one of Monday to Friday. When a slot is booked, public final class Day { public final class Time { (a) Define the class Slot, which has the attributes Day, as above, and Time. In addition to this, it should contain two strings, one for the name of the person booking the room and one for the reason they have for booking it. [3 marks] (b) Define the class Room, such that it has a name, which is a string that cannot be overloaded by derived classes, and an array of 40 slots, one for each available slot in the week. This array should not be visible to other classes, but may need to be to any derived classes. [3 marks] (c) Add to your class a constructor function, which initialises the name of the room, and the time and day in each slot, as well as setting the name and reason to empty strings to indicate that the room has not been booked. [5 marks] (d) Add to your class a method Book, such that it takes an integer parameter which identifies a particular Slot, and two strings giving a name and a meeting, and books the corresponding slot in the room should it be free. The method should return true if the meeting has been successfully booked, and false otherwise. [4 marks] |