[Here is the UML diagram][2][2]: https://i.stack.imgur.com/jSnIn.png
I want to write a python program to implement this diagram. I've created a package called CarPackage and inside of it i've put those 3 classes( Car, Motor, Camera). I don't know exactly how to link classes togheter ,the python sintax gives me trouble.. I've searched over the internet but couldn't find anything useful.
This is my code until now:
class Car:
Motor = []
def __init__(self, Motor, Camera):
self.__Motor = Motor # private attribute
self.__Camera = Camera() # private attribute
def move_forward(self):
print("Moving forward")
def move_backward(self):
print("Moving backward")
def stop(self):
print("The car has stopped")
def take_picture(self):
print("Taking picture...")```
from CarPackage import Car
class Camera(Car):
resolution_X = int
resolution_Y = int
rotation = int
def __init__(self, resolution_X, resolution_Y, rotation):
self.__X = resolution_X
self.__Y = resolution_Y
self.__rot = rotation
def take_picture(fileName):
print("Taking picture...")
from CarPackage import Car
class Motor(Car):
forward_pin = int
backward_pin = int
def __init__(self, forward_pin, backward_pin):
self.__forward = forward_pin # private attribute
self.__backward = backward_pin # private attribute
def move_forward(self):
print("Moving forward")
def move_backward(self):
print("Moving backward")
def stop(self):
print("The car has stopped")