import os
restaurantes = [{'nomne' : 'rua','categoria' :'japonesa', 'ativo': False},
{'nomne' : 'Pizza','categoria':'italiana', 'ativo': True},
{'nomne' : 'cantina', 'categoria':'francesa','ativo': False}]
def exibir_nome_do_programa():
print('''
█▀ ▄▀█ █▄▄ █▀█ █▀█ █▀▀ ▀▄▀ █▀█ █▀█ █▀▀ █▀ █▀
▄█ █▀█ █▄█ █▄█ █▀▄ ██▄ █░█ █▀▀ █▀▄ ██▄ ▄█ ▄█''')
def exibir_opcoes():
print('1. Cadastrar restaurante')
print('2. Listar restaurantes')
print('3. Altenar estado do restaurante')
print('4. Sair\n')
def finalizar_app():
exibir_subtitulo('Finalizar app')
def voltar_ao_menu_principal():
input('\nDigite uma tecla para voltar ao menu principal ')
main()
def opcao_invalida():
print('Opção Inválida!\n')
voltar_ao_menu_principal()
def exibir_subtitulo(texto):
os.system('cls')
linha = '*' * (len(texto))
print(linha)
print(texto)
print(linha)
print()
def cadastrar_novo_restaurante():
'''Essa função é responsável por cadastrar um novo restaurante
inputs:
- Nome do restaurante
- Categoria
Output:
- Adiciona um novo restaurante à lista de restaurantes
'''
exibir_subtitulo('Cadastro de novos restaurantes')
nome_do_restaurante = input('Digita o nome do restaurante que deseja cadastrar: ')
categoria = input(f'Digita o nome da categoria do restaurante {nome_do_restaurante}: ')
dados_do_restaurante = {'nome': nome_do_restaurante,'categoria': 'categoria', 'ativo': False}
restaurantes.append(dados_do_restaurante)
print(f'O restaurante {nome_do_restaurante} foi cadastrado com sucesso!')
voltar_ao_menu_principal()
def listar_restaurantes():
exibir_subtitulo('Listando os restaurantes')
print(f'{'Nome do restaurante'.ljust(22)} | {'Categoria'.ljust(20)} | Status')
for restaurante in restaurantes:
nome_restaurante = restaurante['nome']
categoria_restaurante = restaurante['categoria']
ativo = 'ativado' if restaurante['ativo'] else 'desativado'
print(f' {nome_restaurante.ljust(20)} | {categoria_restaurante.ljust(20)} | {ativo}')
voltar_ao_menu_principal()
def alternar_estado_restaurante():
exibir_subtitulo('ALterando estado do restaurante')
nome_restaurante = input('Digite o nome do restaurante que deseja alterar o estado: ')
restaurante_encontrado = False
for restaurante in restaurantes:
if nome_restaurante == restaurante['nome']:
restaurante_encontrado = True
restaurante['ativo'] = not restaurante['ativo']
mensagem = f'O restaurante {nome_restaurante} foi ativado com sucesso' if restaurante['ativo'] else f'O restaurante {nome_restaurante} foi desativado com sucesso'
print(mensagem)
if not restaurante_encontrado:
print('O restaurante não foi encontrado.')
input('\nDigita uma tecla para voltar ao menu principal. ')
main()