Design Student Room Preference Allocation
Model students, capacity preferences, rooms, assignments, and a waitlist for a small housing allocation domain.
Design the object model and interfaces for assigning students to rooms according to room-capacity preferences. For this exercise, assume each registered room has capacity two or four, each active student chooses exactly one of those capacities, and each student may hold at most one assignment.
Student IDs and room IDs are unique; duplicate registration, unknown IDs, and unsupported capacities produce distinguishable validation errors.
An allocation run processes currently unassigned students in preference-submission order, fills only rooms of the requested capacity, and leaves students waiting when no preferred bed is available.
Calling allocation again returns the student's current Assigned or Waiting state and never creates a duplicate; it need not replay a historical result after promotion or cancellation.
A cancellation releases one bed and offers it to the earliest waiting student for that capacity; cancelling an unassigned student returns NotAssigned without changing state. Preference changes are outside the base exercise, and promotion removes the chosen student from waiting.
Roommate compatibility, payments, buildings, accessibility rules, persistence, and distributed coordination are outside scope. Describe requirements, objects and responsibilities, public interfaces, and the main allocation and cancellation interactions without writing code.