...
The verbal description of this method is "reserve a room for week week
, for name name
". Reserve
- checks whether there is a free room and throws a
NoRoomException
if there isn't - checks whether there already is a reservation for the given name and week, because this constitute an error in our toy-world (see restrictions above) FIXME
- if everything turns out well, a
ReservationInfo
instance with name and week is added to the repository
If the checks give green light,
Reserve
returns the freshly minted IReservationInfo
instance.
...
Cancel
is polymorphic, two versions exist:
IReservationInfo Cancel (IReservationInfo reservationInfo)
is a thin wrapper around the repository'sRemove
methodIReservationInfo Cancel (string name, int week)
is the more convenient relative that does error checking and creates theIReservationInfo
instance for you, from thename
andweek
parameters
Trying to cancel a reservation that does not exist in the repository is an error, of course.