Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
003_oop
class Car:
def __init__(self, brand, color, plate):
self.brand = brand
self.color = color
self.plate = plate
def start(self):
return f'{self.color} {self.brand} started!'
@staticmethod
def stop():
return 'All systems stop!'
def _check(self):
return 'Private method'
def __str__(self):
return f'Brand: {self.brand}, Color: {self.color}, Plate: {self.plate}'
__repr__ = __str__
cars = [Car(brand='Audi', color='Black', plate='XYXY-123'),
Car(brand='BMW', color='Purple', plate='QWER-321')]
print(cars[0])
print(cars[0].start())
print(cars[0].stop())
print(cars[0]._check())
print(cars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment