Exercício 1
class Car:
def __init__(self, model, year, color):
self.model = model
self.year = year
self.color = color
def __str__(self):
return f'Model: {self.model} | Year: {self.year} | Color: {self.color}'
car1 = Car('Toyota Camry', 2020, 'Red')
car2 = Car('Honda Accord', 2019, 'Blue')
car3 = Car('Ford Mustang', 2021, 'Black')
print(car1, car2, car3, sep='\n')
Exercício 2, 3, 4
class Restaurant:
def __init__(self, name, category, rating, active=False):
self.name = name
self.category = category
self.rating = rating
self.active = active
def __str__(self):
return f'Name: {self.name} | Category: {self.category} | Rating: {self.rating} | Active: {self.active}'
restaurant1 = Restaurant('Pasta Palace', 'Italian', 4.5)
restaurant2 = Restaurant('Sushi Central', 'Japanese', 4.8)
restaurant3 = Restaurant('Burger Barn', 'American', 4.2)
print(restaurant1, restaurant2, restaurant3, sep='\n')
Exercício 5
class Customer:
def __init__(self, first_name, last_name, age, email):
self.first_name = first_name
self.last_name = last_name
self.age = age
self.email = email
def __str__(self):
return f'Customer: {self.first_name} {self.last_name}, Age: {self.age}, Email: {self.email}.'
customer = Customer('John', 'Doe', 30, 'john.doe@example.com')
print(customer)