class Restaurante:
def __init__(self, nome,categoria,ativo=False):
self.nome = nome
self.categoria = categoria
self.ativo = ativo
def __str__(self):
return f' Restaurante: {self.nome.ljust(20)} | Categoria: {self.categoria.ljust(20)} | Ativo: {self.ativo}'
restaurante_praca = Restaurante(
nome = 'Praça',
categoria = 'Italiana'
)
print(restaurante_praca.nome)
if restaurante_praca.ativo:
print(f'Restaurante {restaurante_praca.nome} está Ativo.\n')
else:
print(f'Restaurante {restaurante_praca.nome} está Inativo.\n')
categoria_praca = restaurante_praca.categoria
print(categoria_praca)
restaurante_praca.nome = 'Bistrô '
print(restaurante_praca.nome )
restaurante_pizza = Restaurante(
nome = 'Pizza Place',
categoria = 'Fast Food'
)
if restaurante_pizza.categoria == 'Fast Food':
print(f'A categoria do restaurante {restaurante_pizza.nome} é: {restaurante_pizza.categoria} \n')
restaurante_pizza.ativo = True
def exibir():
for indice, restaurante in enumerate(restaurantes, start=1):
print(f'{indice}. {restaurante}')
restaurantes = [restaurante_praca, restaurante_pizza]
exibir()
Resultado:
Praça
Restaurante Praça está Inativo.
Italiana
Bistrô
A categoria do restaurante Pizza Place é: Fast Food
1. Restaurante: Bistrô | Categoria: Italiana | Ativo: False
2. Restaurante: Pizza Place | Categoria: Fast Food | Ativo: True