Ticket Service Project development for DWP coding challenge
TicketService/
├── package.json
├── src/
│ ├── pairtest/
│ │ ├── lib/
│ │ │ ├── InvalidPurchaseException.js
│ │ │ └── TicketTypeRequest.js
│ │ └── TicketService.js
│ └── thirdparty/
│ ├── paymentgateway/
│ │ └── TicketPaymentService.js
│ └── seatbooking/
│ └── SeatReservationService.js
└── test/
└── TicketService.test.js
The main objective of this project is to provide a working implementation of a TicketService
that handles ticket purchases. This exercise allows the demonstration of coding skills, adherence to given business rules, and creation of testable, reusable, and maintainable code.
- Three types of tickets: Infant, Child, and Adult.
- The ticket prices are £0 for Infant, £10 for Child, and £20 for Adult.
- The purchaser declares the type and count of tickets they wish to buy.
- Multiple tickets can be purchased at a time.
- A maximum of 20 tickets can be purchased at once.
- Infants do not pay and do not require a seat.
- Child and Infant tickets cannot be purchased without an Adult ticket.
- The
TicketService
interface should not be modified. - The third-party package code should not be modified.
- The
TicketTypeRequest
should be an immutable object. - All accounts with an ID greater than zero are valid.
- Payment and seat reservation services are assumed to be fault-free.
The project uses the Factory Pattern to create instances of TicketService
. This service validates ticket purchase requests against a set of rules and constraints before proceeding with payment and seat reservation. All of this is done in a modular, testable, and maintainable way.
The code is written in ES6 and strictly adheres to good coding practices, including meaningful variable names and extensive commenting for maximum readability and maintainability.
- Node.js
- npm
- Jest (for testing)
-
Clone the repository to your local machine. git clone https://github.com/moktermd08/TicketService.git
-
Navigate to the project directory. cd TicketService ( project folder name )
-
Install the required packages. npm install
-
Test. npm test