0
respostas

[Projeto] Faça como eu fiz: estruturas de repetição e conjuntos

import os

restaurantes = ['Pizza', 'Sushi']

def exibir_nome_do_programa():
    print("""
░██████╗░█████╗░██████╗░░█████╗░██████╗░  ███████╗██╗░░██╗██████╗░██████╗░███████╗░██████╗░██████╗
██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗  ██╔════╝╚██╗██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝
╚█████╗░███████║██████╦╝██║░░██║██████╔╝  █████╗░░░╚███╔╝░██████╔╝██████╔╝█████╗░░╚█████╗░╚█████╗░
░╚═══██╗██╔══██║██╔══██╗██║░░██║██╔══██╗  ██╔══╝░░░██╔██╗░██╔═══╝░██╔══██╗██╔══╝░░░╚═══██╗░╚═══██╗
██████╔╝██║░░██║██████╦╝╚█████╔╝██║░░██║  ███████╗██╔╝╚██╗██║░░░░░██║░░██║███████╗██████╔╝██████╔╝
╚═════╝░╚═╝░░╚═╝╚═════╝░░╚════╝░╚═╝░░╚═╝  ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░╚═╝╚══════╝╚═════╝░╚═════╝░
      """)

def exibir_opcao():
    print('1. Cadastrar restaurante')
    print('2. Listar restaurante')
    print('3. Ativar restaurante')
    print('4. sair\n ')

def finalizar_app():
    exibir_subtitulo('Finalizar app')
    # os.systen('clear') no mac

def voltar_ao_menu_principal():
    input('\nDigite uma tecla para volta ao menu principal')
    main()

def exibir_subtitulo(texto):
    os.system('cls')
    print(texto)
    print()


def opacao_invalida():
    print('Opcao invalida!\n')
    voltar_ao_menu_principal()

def cadastrar_novo_restaurante():
    exibir_subtitulo('cadastro de novos restaurantes')
    nome_do_restaurante = input('digite o nome do restaurante q deseja cadastrar: ')
    restaurantes.append(nome_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')

    for restaurante in restaurantes:
        print(f'.{restaurante}')


    voltar_ao_menu_principal()

def escolher_opcao():
    try:
        opacao_escolhida = int(input('Escolha uma opcao: '))
        # opacao_escolhida = int(opacao_escolhida)

        if opacao_escolhida == 1:
            cadastrar_novo_restaurante()
            print('Cadastrar restaurante')
        elif opacao_escolhida == 2:
            listar_restaurantes()
        elif opacao_escolhida == 3:
            print('Ativar restaurante')
        elif opacao_escolhida == 4:
            finalizar_app()
        else:
            opacao_invalida()
    except:
        opacao_invalida()

def main():
    os.system('cls')
    exibir_nome_do_programa()
    exibir_opcao()
    escolher_opcao()

if __name__ == '__main__':
    main()