Skip to content

vehicle

Module: Vehicle and vehicle types.

Car

Bases: Vehicle

Class: Car.

Source code in parking_lot/src/vehicle.py
34
35
36
37
38
class Car(Vehicle):
    """Class: Car."""

    def __init__(self, vehicle_id: int):
        super().__init__(vehicle_id, VehicleType.CAR)

Factory

Bases: ABC

Class: Factory to create vehicle instances.

Source code in parking_lot/src/vehicle.py
55
56
57
58
59
60
class Factory(ABC):
    """Class: Factory to create vehicle instances."""

    @abstractmethod
    def factory_method(self, vehicle_id) -> Vehicle:
        pass

Motorbike

Bases: Vehicle

Class: Motorbike.

Source code in parking_lot/src/vehicle.py
48
49
50
51
52
class Motorbike(Vehicle):
    """Class: Motorbike."""

    def __init__(self, vehicle_id: int):
        super().__init__(vehicle_id, VehicleType.MOTORBIKE)

Truck

Bases: Vehicle

Class: Truck.

Source code in parking_lot/src/vehicle.py
41
42
43
44
45
class Truck(Vehicle):
    """Class: Truck."""

    def __init__(self, vehicle_id: int):
        super().__init__(vehicle_id, VehicleType.TRUCK)

Vehicle

Class: Vehicle.

Source code in parking_lot/src/vehicle.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Vehicle:
    """Class: Vehicle."""

    def __init__(self, vehicle_id: int, vehicle_type: VehicleType):
        """Initializes Vehicle instance

        Args:
            vehicle_id (int): Unique identifier of vehicle
            vehicle_type (Enum): Vehicle type Enum
        """
        self.vehicle_id = vehicle_id
        self.vehicle_type = vehicle_type
        self.ticket = None

    def __str__(self):
        class_name = type(self).__name__
        return f"{class_name}(vehicle_id={self.vehicle_id}, vehicle_type={self.vehicle_type})"

__init__(vehicle_id, vehicle_type)

Initializes Vehicle instance

Parameters:

Name Type Description Default
vehicle_id int

Unique identifier of vehicle

required
vehicle_type Enum

Vehicle type Enum

required
Source code in parking_lot/src/vehicle.py
18
19
20
21
22
23
24
25
26
27
def __init__(self, vehicle_id: int, vehicle_type: VehicleType):
    """Initializes Vehicle instance

    Args:
        vehicle_id (int): Unique identifier of vehicle
        vehicle_type (Enum): Vehicle type Enum
    """
    self.vehicle_id = vehicle_id
    self.vehicle_type = vehicle_type
    self.ticket = None

VehicleType

Bases: str, Enum

Types of vehicles.

Source code in parking_lot/src/vehicle.py
 7
 8
 9
10
11
12
class VehicleType(str, Enum):
    """Types of vehicles."""

    CAR = "car"
    TRUCK = "truck"
    MOTORBIKE = "motorbike"