Introducing Typescript: Language features
The following post describes a parking lot using Typescript and OOP pattern, the scope of the demo is shows some Typescript language features.
Introducing Typescript and setup project
Design an OO parking lot using typescript language features
We’re going to implement a generic parking lot ticketing system, using the following classes and interfaces:
The Ticket class is used by Vehicle class: it describes the associations between the parked Vehicle and the entering ticket. It defines an id, entry and exit Date. The id is calculated using the combination between current time and license plate of car.
The Car extends Vehicle class, and it adds additional information: car insurance.
The Vehicle class can be eventually extended to add other vehicle types.
The Parking lot is described using a combination between an interface and a class: the interface contains functions signatures, and the concrete class contains an array that is used as a Vehicles container.
ParkingLot uses custom find method that can find objects inside arrays.
The sources are available on github