lista_de_restaurantes = [{"nome": "Mc Donalds", "categoria": "Hamburguers", "estado": True},
{"nome": "Pizza Hut", "categoria": "Pizzas", "estado": False},
{"nome": "Casa do Pastel", "categoria": "Pastéis", "estado": False}]
[...]
def cadastrar_restaurante():
exibir_subtitulos ("Cadastro de Restaurantes")
nome_do_restaurante = input ("Digite o nome do restaurante a ser cadastrado: ")
categoria_restaurante = input ("Digite a categoria do restaurante: ")
dados_do_restaurante = {"nome": nome_do_restaurante, "categoria": categoria_restaurante, "estado": False}
lista_de_restaurantes.append (dados_do_restaurante)
print (f"Restaurante {nome_do_restaurante} cadastrado com sucesso!")
retornar_ao_menu()
def listar_restaurantes():
exibir_subtitulos ("Lista de Restaurantes")
print (f"{"Nome do Restaurante".ljust(28)} | {"Categoria".ljust(25)} | {"Estado".ljust(25)}\n")
for restaurante_indice in lista_de_restaurantes:
nome_restaurante = restaurante_indice["nome"]
categoria_restaurante = restaurante_indice["categoria"]
status_restaurante = "Ativo" if restaurante_indice["estado"] else "Inativo"
print (f"* {nome_restaurante.ljust(25)} | {categoria_restaurante.ljust(25)} | {status_restaurante.ljust(25)}")
retornar_ao_menu()
def mudar_estado_restaurante():
exibir_subtitulos ("Alterando restaurante do restaurante")
nome_do_restaurante = input ("Digite o nome do restaurante: ")
restaurante_encontrado = False
for restaurante_indice in lista_de_restaurantes:
if nome_do_restaurante == restaurante_indice["nome"]:
restaurante_encontrado = True
restaurante_indice["estado"] = not restaurante_indice["estado"]
mensagem = f"O restaurante {nome_do_restaurante} foi ativado com sucesso!" if restaurante_indice["estado"] else f"O restaurante {nome_do_restaurante} foi desativado com sucesso!"
print (mensagem)
if not restaurante_encontrado:
print ("Restaurante não foi encontrado!")
retornar_ao_menu()