This was a javascript assessment project assigned by DWP. I was tasked to make working cinema ticket service.
-
There are 3 types of tickets i.e. Infant, Child, and Adult.
-
The ticket prices are based on the type of ticket (see table below).
-
The ticket purchaser declares how many and what type of tickets they want to buy.
-
Multiple tickets can be purchased at any given time.
-
Only a maximum of 20 tickets that can be purchased at a time.
-
Infants do not pay for a ticket and are not allocated a seat. They will be sitting on an Adult's lap.
-
Child and Infant tickets cannot be purchased without purchasing an Adult ticket.
| Ticket Type | Price |
|---|---|
| INFANT | £0 |
| CHILD | £10 |
| ADULT | £20 |
-
There is an existing
TicketPaymentServiceresponsible for taking payments. -
There is an existing
SeatReservationServiceresponsible for reserving seats.
-
The TicketService interface CANNOT be modified. (For Java solution only)
-
The code in the thirdparty.* packages CANNOT be modified.
-
The
TicketTypeRequestSHOULD be an immutable object.
You can assume:
-
All accounts with an id greater than zero are valid. They also have sufficient funds to pay for any no of tickets.
-
The
TicketPaymentServiceimplementation is an external provider with no defects. You do not need to worry about how the actual payment happens. -
The payment will always go through once a payment request has been made to the
TicketPaymentService. -
The
SeatReservationServiceimplementation is an external provider with no defects. You do not need to worry about how the seat reservation algorithm works. -
The seat will always be reserved once a reservation request has been made to the
SeatReservationService.
Provide a working implementation of a TicketService that:
-
Considers the above objective, business rules, constraints & assumptions.
-
Calculates the correct amount for the requested tickets and makes a payment request to the
TicketPaymentService. -
Calculates the correct no of seats to reserve and makes a seat reservation request to the
SeatReservationService. -
Rejects any invalid ticket purchase requests. It is up to you to identify what should be deemed as an invalid purchase request.”
git clone https://github.com/Abid-dev/cinema-tickets-js.git
cd cinema-tickets-js
npm installTo run the program locally on your browser, run the following command:
node app.jsYou should be able to view and play around with it on your localhost port 3000.
