Design a Study Room Booking System
Model a small library's study-room bookings: book a room for a time slot, cancel by booking ID, list a room's bookings, and reject overlapping bookings.
Design the classes for a basic booking system. Members of a small library book study rooms for a time slot, cancel bookings they no longer need, and see the bookings for a room.
The interview report behind this problem only says the task was a "basic OOP booking system" and gives no other details, so the study-room scenario in this prompt is our practice version of that task.
For this exercise, assume the library has a fixed set of study rooms, each with a unique room ID, set up before any booking is made. Everything is in memory and handled one call at a time. A member books a room by giving the room ID, their name, a start time and an end time.
Times are whole minutes on one shared timeline, and a booking covers the half-open interval [start, end), so the start must be earlier than the end. A successful booking gets a unique booking ID.
For this exercise, assume two active bookings for the same room may never overlap, but they may touch: a booking from 10:00 to 11:00 and another from 11:00 to 12:00 in the same room are both allowed. Bookings in different rooms never conflict.
A booking for an unknown room, a start that is not earlier than the end, or a time slot that overlaps an active booking in that room is rejected.
For this exercise, assume a member cancels by booking ID. A cancelled booking no longer blocks its time slot and no longer appears in the room's list. Cancelling an unknown booking ID, or a booking that is already cancelled, is rejected.
Listing a room's bookings returns its active bookings in order of start time; listing an unknown room is rejected. A rejected call changes nothing.
Editing or moving a booking, recurring bookings, opening hours, limits per member, sign-in and permissions, payments, notifications, persistence and concurrent access are outside scope. Design the objects, their method contracts and one interaction walkthrough. No implementation code is required.