Design Parking System

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.
Implement the ParkingSystem class:
ParkingSystem(int big, int medium, int small)Initializes object of theParkingSystemclass. The number of slots for each parking space are given as part of the constructor.bool addCar(int carType)Checks whether there is a parking space ofcarTypefor the car that wants to get into the parking lot.carTypecan be of three kinds: big, medium, or small, which are represented by1,2, and3respectively. A car can only park in a parking space of itscarType. If there is no space available, returnfalse, else park the car in that size space and returntrue.LeetCode Problem - 1603
class ParkingSystem { // Variables to track available parking spaces for each type of car int big, medium, small; // Constructor to initialize the number of parking spaces for each car type public ParkingSystem(int big, int medium, int small) { this.big = big; // Number of spaces available for big cars this.medium = medium; // Number of spaces available for medium cars this.small = small; // Number of spaces available for small cars } // Method to add a car of the specified type public boolean addCar(int carType) { // Check if there are no available spaces for the given car type if ((carType == 1 && !(big > 0)) || (carType == 2 && !(medium > 0)) || (carType == 3 && !(small > 0))) { return false; // Return false if no space is available for this car type } // Decrement the corresponding parking space count based on the car type if (carType == 1) { big--; // Decrease big car spaces } else if (carType == 2) { medium--; // Decrease medium car spaces } else { small--; // Decrease small car spaces } return true; // Return true if the car was successfully parked } } /** * Example usage: * ParkingSystem obj = new ParkingSystem(big, medium, small); * boolean param_1 = obj.addCar(carType); * * - `big`, `medium`, and `small` specify the initial number of spaces for each type of car. * - `carType` is 1 (big), 2 (medium), or 3 (small). * - The `addCar` method returns true if a car of the given type can be parked, false otherwise. */




