Sie sind auf Seite 1von 5

Assignment 1 Notes

General requirements
All input will be a sequence of lines of the following form:

Venue <name> <roomname> <type>


o specify that venue <name> has a room with name <roomname>
that has size <type>

Request <id> <month1> <date1> <month2> <date2> <number1>


<type1> <number2> <type2> . . .
o request <id> is from <month1>, <date1> to <month2>,
<date2> for <number1> rooms of <type1>, etc.

Change <id> <month1> <date1> <month2> <date2> <number1>


<type1> <number2> <type2> . . .
o change reservation <id> to <month1>, <date1> to <month2>,
<date2> with <number1> rooms of <type1>, etc.

Cancel <id>
o cancel reservation <id> (if it exists) and free up rooms

Print <name>
o print occupancy of each room in the venue <name>

All venues will be declared before any commands are issued.

Assumptions

Assume all dates are in 2016


Assume that each reservation request (and similarly for change requests) has at
most one request for a room of a given type (e.g. does not ask for small rooms more
than once).
o Dont try to fulfil requests by allocating larger rooms when a small room is
requested, or
o Reassigning rooms to different reservations to create space etc.
Assume that reservation ids are unique
Assume that all venue names are declared at the start of the file.
Print out months in the standard three letter format e.g. JAN
Assume that if a request is made with a booking id, another request with the same
booking id will never be made unless it is cancelled.

Reservations and Requests


Each venue is checked to determine whether every room request can be satisfied. If so, the
first available rooms are assigned to the reservation. The checking and assigning of rooms
are done in order of definition.
The output should list rooms assigned to the reservation in order of the declarations at the
start of the file (see Sample IO)
Assume input only requests for a room of a given type at most once.
Do not fulfil requests by allocating larger rooms when a small room is requested, or by
reassigning rooms to different reservations to create space.
For printing, output the occupancy of all rooms at the specified venue in order of room
declaration, then date.
Venue names shall be one word only. We may assume that reservation ids are unique and
that all venue names are declared at the start of the file.

Test Cases
Booking request:
1.
2.
3.
4.

There exists no other booking at all.


There exists no other booking with an overlapping date.
There exists a booking with an overlapping date, but uses a different venue.
There exists a booking with an overlapping date, and uses the same venue.
There are sufficient rooms available left.
5. There exists a booking with an overlapping date, and uses the same venue.
There are no sufficient rooms available left.
Possible overlapping date period cases:
1. If starting date <= comparison starting date && ending date >= comparison ending
date
2. If starting date >= comparison starting date && starting date <= comparison ending
date
3. If ending date >= comparison starting date && ending date <= comparison ending
date
Booking cancel:
1. The booking exists. Proceed to cancel.
2. Booking doesnt exist. Reject cancel command as there is nothing to cancel.

Housekeeping
All Java source files should be in the default package.
Main class shall be called VenueHireSystem.java.

I/O
Input shall be done as a text file name argument passed into the main method in the call
java VenueHireSystem.
Print output should be directed to System.out.
If a reservation request cannot be fulfilled, print out Request rejected.
If a change cannot be made, print out Change rejected.
If a cancellation cannot be done, print out Cancel rejected.
To read input from a text file, use code such as:
Scanner sc = null;
try
{
sc = new Scanner(new FileReader(args[0]));
first command line argument
}
catch (FileNotFoundException e) {}
finally
{
if (sc != null) sc.close();
}

# args[0] is the

Sample IO
Input

Venue Zoo Penguin small


which is small

# Venue Zoo has the Penguin room

Venue Zoo Hippo large


which is large

# Venue Zoo has the Hippo room

Venue Zoo Elephant large


room which is large

# Venue Zoo has the Elephant

Venue Gardens Figtree large


room which is large

# Venue Gardens has the Figtree

Request 1 Mar 25 Mar 26 1 large 1 small


# Request 1 is for 1 large and 1 small room from Mar
25 to Mar 26
# Assign Penguin and Hippo rooms of Zoo (output
Reservation 1 Zoo Penguin Hippo)

Request 2 Mar 24 Mar 27 1 large


# Request 2 is for 1 large room from Mar 24 to Mar
27
# Assign Elephant room of Zoo since Hippo room is
occupied (output Reservation 2 Zoo Elephant)

Request 3 Mar 26 Mar 26 1 large


# Request 3 is for 1 large room from Mar 26 to Mar
26
# Assign Figtree room of Gardens (output Reservation
3 Gardens Figtree)

Change 1 Mar 27 Mar 29 1 small


# Change reservation 1 to 1 small room from Mar 27
to Mar 29
# Deassign Penguin and Hippo rooms of Zoo and assign
Penguin room of Zoo (output Change 1 Zoo Penguin)

Request 4 Mar 25 Mar 26 1 small


# Request 4 is for 1 small room from Mar 25 to Mar
26
# Assign Penguin room of Zoo (output Reservation 4
Zoo Penguin)

Cancel 3
# Cancel reservation 3
# Deassign Figtree room of Gardens (output Cancel
3)Request 5 Mar 26 Mar 26 1 small
# Request 5 is for 1 small room from Mar 26 to Mar
26
# Request cannot be fulfilled (output Request
rejected)

Print Zoo
# Print out occupancy of all rooms at Zoo, in order
of room declarations, then date;
# for each reservation giving the start date and
number of days occupied

Output

Reservation 1 Zoo Penguin Hippo

Reservation 2 Zoo Elephant

Reservation 3 Gardens Figtree

Change 1 Zoo Penguin

Reservation 4 Zoo Penguin

Cancel 3

Request rejected

Zoo Penguin Mar 25 2 Mar 27 3

Zoo Hippo

Zoo Elephant Mar 24 4

Das könnte Ihnen auch gefallen