import os
import msvcrt
def limpar_tela():
os.system("cls" if os.name == "nt" else "clear")
def pausa_limpa(texto):
print(texto, end="", flush=True)
voltar = msvcrt.getch()
limpar_tela()
def voltar_menu():
print("\nVoltar ao menu principal...", end="", flush=True)
voltar = msvcrt.getch()
def exibir_subtitulo(texto):
limpar_tela()
linha = '-' * (len(texto) + 4)
print(linha)
print(" ", texto)
print(linha)
print()
restaurantes = [{"nome":"JSK", "categoria":"Hamburgueria", "ativo": True},
{"nome":"Spoleto", "categoria":"Massas", "ativo": False}]
def exibir_nome_programa_e_opcoes():
print("""
░██████╗░█████╗░██████╗░░█████╗░██████╗░ ███████╗██╗░░██╗██████╗░██████╗░███████╗░██████╗░██████╗
██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗ ██╔════╝╚██╗██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝██╔════╝
╚█████╗░███████║██████╦╝██║░░██║██████╔╝ █████╗░░░╚███╔╝░██████╔╝██████╔╝█████╗░░╚█████╗░╚█████╗░
░╚═══██╗██╔══██║██╔══██╗██║░░██║██╔══██╗ ██╔══╝░░░██╔██╗░██╔═══╝░██╔══██╗██╔══╝░░░╚═══██╗░╚═══██╗
██████╔╝██║░░██║██████╦╝╚█████╔╝██║░░██║ ███████╗██╔╝╚██╗██║░░░░░██║░░██║███████╗██████╔╝██████╔╝
╚═════╝░╚═╝░░╚═╝╚═════╝░░╚════╝░╚═╝░░╚═╝ ╚══════╝╚═╝░░╚═╝╚═╝░░░░░╚═╝░░╚═╝╚══════╝╚═════╝░╚═════╝░
1. Cadastrar restaurante
2. Listar restaurante
3. Ativar/desativar restaurante
4. Apagar restaunte
5. Sair
""")
def cadastrar_restaurantes():
exibir_subtitulo("Cadastro de novos restaurantes")
while True:
nome = input("Digite o nome do restaurante que deseja cadastrar (ou 's'/'sair' para voltar): ").strip()
if nome.lower() in ("s", "sair"):
break
if not nome:
print("Nome vazio não é válido.\n")
continue
if any(restaurante["nome"].lower() == nome.lower() for restaurante in restaurantes):
print(f"\nO restaurante {nome.title()} já está cadastrado.\n")
pausa_limpa("Continuar...")
continue
while True:
categoria = input(f"\nDigite a categoria do restaurante {nome.title()} (ex.: Hamburgueria, Massas): ").strip()
if not categoria:
print("Categoria vazia não é válida\n")
continue
else:
break
restaurantes.append({
"nome": nome.title(),
"categoria": categoria.title(),
"ativo": False
})
print(f"\nRestaunte {nome.title()} cadastrado com sucesso!\n")
pausa_limpa("Continuar...")
voltar_menu()
def listar_restaurantes():
exibir_subtitulo("Restaurantes cadastrados")
if not restaurantes:
print("Nenhum restaurante cadastrado.")
else:
print(f" {"Restaurante".ljust(25)}{"Categoria".ljust(23)}{"Status"}")
for i, restaurante in enumerate(restaurantes, start = 1):
ativo = "ativo" if restaurante["ativo"] else "desativado"
#print(f"Restaurante {i}. Nome: {restaurante["nome"].ljust(20)} | Categoria: {restaurante["categoria"].ljust(20)} | Estado atual: {ativo}")
print(f"{i}. {restaurante["nome"].ljust(20)} | {restaurante["categoria"].ljust(20)} | {ativo}")
voltar_menu()
def alternar_estado_restaurantes():
exibir_subtitulo("Ativar/Desativar Restaurantes")
while True:
nome = input("Digite o nome do restaurante que deseja ativar/desativar (ou 's'/'sair' para voltar): ").strip()
if nome.lower() in ("s", "sair"):
break
if not nome:
print("Nome vazio não é válido.\n")
continue
for restaurante in restaurantes:
if nome.lower() == restaurante["nome"].lower():
ativo = "ativado" if restaurante["ativo"] else "desativado"
print(f"\nRestaurante {nome.title()} está {ativo} no momento.")
resposta = input("\nDeseja mudar o estado ('s' ou 'n'): ").strip().lower()
if resposta in ("s", "sim"):
restaurante["ativo"] = not restaurante["ativo"]
ativo = "ativado" if restaurante["ativo"] else "desativado"
print(f"\nO restaurante {nome.title()} agora está {ativo}.\n")
else:
print("\nSem alterações.\n")
break
else:
print("Restaurante não cadastrado.\n")
pausa_limpa("Continuar...")
voltar_menu()