Skip to content

Vehicle

Vehicle

This is a vehicle class. It has a number of wheels.

Source code in src/vehicle.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Vehicle():
    '''
    This is a vehicle class. It has a number of wheels.
    '''

    def __init__(self, num_of_wheels: int):
        '''
        To initialise a vehicle by supplying the number of wheels

        Args:
            num_of_wheels (int): number of wheels a vehicle has
        '''
        self._num_of_wheels = num_of_wheels

    @property
    def num_of_wheels(self) -> int:
        '''
        To access the number of wheels a vehicle can have

        Returns:
            int: the number of wheels specified
        '''
        return self._num_of_wheels

num_of_wheels: int property

To access the number of wheels a vehicle can have

Returns:

Name Type Description
int int

the number of wheels specified

__init__(num_of_wheels)

To initialise a vehicle by supplying the number of wheels

Parameters:

Name Type Description Default
num_of_wheels int

number of wheels a vehicle has

required
Source code in src/vehicle.py
 6
 7
 8
 9
10
11
12
13
def __init__(self, num_of_wheels: int):
    '''
    To initialise a vehicle by supplying the number of wheels

    Args:
        num_of_wheels (int): number of wheels a vehicle has
    '''
    self._num_of_wheels = num_of_wheels