- Classes can be of multiple types - yoga, gym, dance.
- Each class has a capacity. This refers to the maximum number of users that can attend the class.
- Users can book a class if the capacity is not yet reached.
- If a class is already at capacity, the system should maintain a waiting list of interested users.
- Users can cancel the slot upto 30 mins before the class starts. When a user cancels their booking, allocate the canceled slot to the first user from the waitlist.
The app contains two files :
Book.java
contains the bussiness logic of the appClasses.java
contains the main class for storing classes and their attributes likecurrentUsers
,currentSlots
, etc.
The Classes.java
contains methods to check if user can cancel a class, join a class, check if a class is full, update the queue, etc.
- To add a class, input the class details like
Name
,totalSlots
, etc.
- To join a class, input your
userName
and theclassName
you want to join.
- If the class is full, the user is added to a
queue
and the error message and queue is displayed.
- I haven't made an extra class for
User
as we were allowed to use just names for the app functioning. - The code might feel less modular due to time constraint, otherwise I would have seperated the database operations from
Book.java
altogether. - I have used a simple array for storing the queue of users, could have used
Queue
data structure.