{"id":20826741,"url":"https://github.com/cedrickchee/parkinglot-ts-node","last_synced_at":"2025-03-12T07:23:40.580Z","repository":{"id":138118470,"uuid":"229700339","full_name":"cedrickchee/parkinglot-ts-node","owner":"cedrickchee","description":"TypeScript solution for parking lot problem.","archived":false,"fork":false,"pushed_at":"2019-12-23T07:32:09.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T17:49:37.248Z","etag":null,"topics":["algorithm","data-structures","oop-concepts","parking-lot","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cedrickchee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-23T07:30:21.000Z","updated_at":"2024-11-01T11:33:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9b4d047-7177-49a4-9664-3a3ba977ea13","html_url":"https://github.com/cedrickchee/parkinglot-ts-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fparkinglot-ts-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fparkinglot-ts-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fparkinglot-ts-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrickchee%2Fparkinglot-ts-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cedrickchee","download_url":"https://codeload.github.com/cedrickchee/parkinglot-ts-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243174020,"owners_count":20248218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","data-structures","oop-concepts","parking-lot","typescript"],"created_at":"2024-11-17T23:09:54.828Z","updated_at":"2025-03-12T07:23:40.572Z","avatar_url":"https://github.com/cedrickchee.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parking Lot Algorithm\n\nThis project describes and solves the parking lot problem using TypeScript and Object-Oriented Programming pattern.\n\n## The problem\n\nDesign an Object-Oriented parking lot using any programming language features.\n\n## The Solution\n\n### Model\n\nWe're going to implement a generic parking lot ticketing system, using the following classes and interfaces:\n\n- Ticket\n- Vehicle, Car\n- Parking Lot\n\n### Ticket\n\nThe **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.\n\n```txt\n\n-------------------------\n|        Ticket         |\n|-----------------------|\n| + id: string          |\n| + enterDate: DateTime |\n| + exitDate: DateTime  |\n-------------------------\n\n```\n\n### Vehicle\n\nThe **Vehicle** class contains some attributes about Vehicle _dimensions_, and _brand_ and the _license plate_. It also contains the methods to park/exit the Vehicles from Parking lot.\n\nThe **Car** extends Vehicle class, and it adds additional information: _is electric car_. The Vehicle class can be eventually extended to add other vehicle types.\n\n```txt\n\n    -----------------------------\n    |          Vehicle          |\n    |---------------------------|\n    | + color: string           |\n    | + brand: string           |\n    | + height: number          |\n    | + weight: number          |\n    | + ticket: Ticket          |\n    | + isParked: boolean       |\n    |---------------------------|\n    | + Vehicle(): void         |\n    | + parkVehicle(): Ticket   |\n    | + leaveVehicle(): Vehicle |\n    -----------------------------\n                 ^\n                 |\n              Extends\n                 |\n------------------------------------\n|                Car               |\n|----------------------------------|\n| + licensePlate: string           |\n| + isElectricCar: boolean         |\n|----------------------------------|\n| + constructor(class_param): void |\n------------------------------------\n\n```\n\n### Parking Lot\n\nThe **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.\n\n```txt\n\n      --------------------------------\n      |         \u003c\u003cinterface\u003e\u003e        |\n      |       ParkingLot\u003cV, T\u003e       |\n      |------------------------------|\n      | + parkVehicle(vehicle: V): T |\n      | + leaveVehicle(ticket: T): V |\n      --------------------------------\n                    ^\n                    |\n                 Extends\n                    |\n-------------------------------------------\n|             ParkingLotImpl              |\n|-----------------------------------------|\n| + address: string                       |\n| + maxSize: number                       |\n| + availableSlots: array                 |\n|-----------------------------------------|\n| + parkVehicle(vehicle: Vehicle): Ticket |\n| + leaveVehicle(ticket: Ticket): Vehicle |\n-------------------------------------------\n\n```\n\n## How to Use this Project\n\n- Install all dependencies:\n\n```sh\n$ git clone {repo url}\n$ cd parkinglot-ts-node\n$ npm install\n```\n\n- Build binary:\n\n```sh\n$ npm build\n$ npm link\n```\n\n- Run the main program:\n  For interactive mode:\n\n```sh\n$ parkinglot\n```\n\nFor file mode:\n_TODO_\n\n```sh\n$ parkinglot ./data/inputs.txt\n```\n\n- Run tests cases:\n\n```sh\n$ npm test test/run.testcases.js\n```\n\n**Test Inputs:**\n\nFor interactive mode.\n\n```sh\ncreate_parking_lot 6\npark KA-01-HH-1234 White\npark KA-01-HH-9999 White\npark KA-01-BB-0001 Black\npark KA-01-HH-7777 Red\npark KA-01-HH-2701 Blue\npark KA-01-HH-3141 Black\nleave 4\nstatus\npark KA-01-P-333 White\npark DL-12-AA-9999 White\nregistration_numbers_for_cars_with_colour White\nslot_numbers_for_cars_with_colour White\nslot_number_for_registration_number KA-01-HH-3141\nslot_number_for_registration_number MH-04-AY-1111\n```\n\n**Test Outputs:**\n\n```sh\nCreated a parking lot with 6 slots\nAllocated slot number: 1\nAllocated slot number: 2\nAllocated slot number: 3\nAllocated slot number: 4\nAllocated slot number: 5\nAllocated slot number: 6\nSlot number 4 is free\nSlot No.    Registration No     Colour\n1           KA-01-HH-1234       White\n2           KA-01-HH-9999       White\n3           KA-01-BB-0001       Black\n5           KA-01-HH-2701       Blue\n6           KA-01-HH-3141       Black\nAllocated slot number: 4\nSorry, parking lot is full\nKA-01-HH-1234, KA-01-HH-9999, KA-01-P-333\n1, 2, 4\n6\nNot found\n```\n\n## API\n\n- `create(numLots: number): number`\n  - Creates the parking spaces.\n  - Input parameters:\n    - `numLots`: number - bound parameter for the parking slot array.\n  - Command format: `create_parking_lot {number of lots}`. Example: `create_parking_lot 6`.\n- `parkVehicle(vehicle: V): string`\n  - Parks a car to the first available slot.\n  - Input parameters:\n    - `vehicle`: Vehicle - bound parameter for the vehicle object. Example, a car object that has white color and some licence plate.\n  - Command format: `park {license plate} {color}`. Example: `park KA-01-HH-1234 White`.\n- `leave(slot: number): string`\n  - Remove the cark from parking lot.\n  - Command format: `leave {slot number}`. Example: `leave 3`.\n- `status(): string`\n  - Gets the current status for the parking lot.\n  - Command format: `status`.\n- `getLicensePlateFromColor(color: string): string`\n  - Search and get license plate from car color.\n  - Command format: `registration_numbers_for_cars_with_colour {color}`. Example: `registration_numbers_for_cars_with_colour White`.\n- `getSlotNumbersFromColor(color: string): string`\n  - Search and get slot numbers from car color.\n  - Command format: `slot_numbers_for_cars_with_colour {color}`. Example: `slot_numbers_for_cars_with_colour White`.\n- `getSlotNumberFromLicensePlate(licensePlate: string): string`\n  - Search and get slot number from license plate.\n  - Command format: `slot_number_for_registration_number {licence plate}`. Example: `slot_number_for_registration_number KA-01-HH-3141`.\n\n## Plan\n\n- Setup test suite and write comprehensive unit tests.\n- Rewrite the command line parser so that it supports both file input and interactive input in one binary.\n- A better way to solve the problem is using data structures optimized for complexity.\n- Parking lot problem extended - the parking space should accept three different types of vehicles, namely, motorcycle, car, bus.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrickchee%2Fparkinglot-ts-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedrickchee%2Fparkinglot-ts-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrickchee%2Fparkinglot-ts-node/lists"}