c++ – Leetcode 1603. Design Parking System

Description of the problem:

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 the ParkingSystem class. 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 of carType for the car that wants to get into the parking lot. carType can be of three kinds: big, medium, or small, which are represented by 1, 2, and 3 respectively. A car can only park in a parking space of its carType. If there is no space available, return false, else park the car in that size space and return true.

Below is my code, I would appreciate any suggestions on how to improve the code.

#include <iostream>

class ParkingSystem {
    ParkingSystem(int big, int medium, int small) :
    bool addCar(int carType) {
        if (carType == 1) {
            // big car
            if (m_big_curr == m_big_max) {
                return false;
            } else {
        } else if (carType == 2) {
            // medium car
            if (m_medium_curr == m_medium_max) {
                return false;
            } else {
        } else {
            // small car
            if (m_small_curr == m_small_max) {
                return false;
            } else {
        return true;
    int m_big_max;
    int m_medium_max;
    int m_small_max;
    int m_big_curr;
    int m_medium_curr;
    int m_small_curr;

int main() {
    ParkingSystem parking_system(1, 1, 0);
    std::cout << "parking_system.addCar(1) " << parking_system.addCar(1) << std::endl;
    std::cout << "parking_system.addCar(2) " << parking_system.addCar(2) << std::endl;
    std::cout << "parking_system.addCar(3) " << parking_system.addCar(3) << std::endl;
    std::cout << "parking_system.addCar(1) " << parking_system.addCar(1) << std::endl;

    return 0;