Sem resumo de edição |
Sem resumo de edição |
||
| Linha 1: | Linha 1: | ||
<syntaxhighlight lang="py"> | <syntaxhighlight lang="py"> | ||
# 16/06/2017 17:14 | |||
def delete_rest() | def delete_rest() | ||
nome = input() | nome = input() | ||
| Linha 171: | Linha 172: | ||
arquivo.close() | arquivo.close() | ||
% 17/06/2017 00:49 | |||
def delete_rest(): | def delete_rest(): | ||
nome = input() | nome = input() | ||
Edição das 22h25min de 17 de junho de 2017
<syntaxhighlight lang="py">
- 16/06/2017 17:14
def delete_rest() nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') k = -1; for linha in texto lista = linha.split() if lista[0] == nome k = 0 if k != -1 k+=1 if k == -1 arquivo.writelines(linha) if k == 4 k = -1 arquivo.close()
def att_inf_rest() rest = input() inf = input() nova = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = -1 while linha < len(texto) lista = linha.append() if lista[0] == rest if inf == cnpj h = 1 elif inf == endereco h = 2 els linha += 5
def add_card() nome = input() tipo = input() novo = input() preco = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -1 for linha in texto lista = linha.split() if lista[0] == nome g = 0 if tipo == 'entrada' h = 1 elif tipo == 'principal' h = 2 elif tipo == 'sobremesa' h = 3 else h = 4 if g != -1 g++ if g == h k = len(linha) linha[k-1] = ' ' linha += novo linha += ' ' linha += preco arquivo.writelines(linha) arquivo.close()
def del_card() rest = input() tipo = input() comida = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() h = 0 g = -1 for linha in texto lista = linha.split() if lista[0] == nome g = 0 if tipo == 'entrada' h = 1 elif tipo == 'principal' h = 2 elif tipo == 'sobremesa' h = 3 else h = 4 v = 0; if g != -1 g++ if g == h for i in linha if i == comida i = v = 1 if v == 1 i = break arquivo.writelines(linha) arquivo.close()
def read() lista = [] nome = input() lista.append(nome+) cnpj = input() lista.append(cnpj+) endereco = input() lista.append(endereco+) telefone = input() lista.append(telefone+'\n') return lista
def criar_rest()
restaurante = read()
arquivo = open('dados.txt', 'a')
arquivo.writelines(restaurante)
entrada = input()
precoe = input()
principal = input()
precop = input()
sobremesa = input()
precos = input()
bebida = input()
precob = input()
en = []
en.append(entrada+)
en.append(precoe+'\n')
pri = []
pri.append(principal+)
pri.append(precop+'\n')
sob = []
sob.append(sobremesa+)
sob.append(precos+'\n')
be = []
be.append(bebida+)
be.append(precob+'\n')
arquivo.writelines(en)
arquivo.writelines(pri)
arquivo.writelines(sob)
arquivo.writelines(be)
arquivo.close()
def procurar_rest() nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() j = 0 while i < len(texto): lista = i.split() if lista[0] == nome print(lista) j = 1 break i+=5 if j == 0 print('Restaurante nao encontrado') arquivo.close()
% 17/06/2017 00:49 def delete_rest(): nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') k = -2; for linha in texto: lista = linha.split() if lista[0] == nome: k = -1 if k != -2: k+=1 if k == -1: arquivo.writelines(linha) if k == 4: k = -1 arquivo.close()
def add_card(): nome = input() tipo = input() novo = input() preco = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -1 for linha in texto: lista = linha.split() if lista[0] == nome: g = 0 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 if g != -1: g+=1 if g == h: k = len(linha) linha += novo linha += ' ' linha += preco linha += ' ' arquivo.writelines(linha) arquivo.close()
def del_card(): rest = input() tipo = input() comida = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() arquivo.close() arquivo = open('dados.txt', 'w') h = 0 g = -2 for linha in texto: lista = linha.split() if lista[0] == rest: g = -1 if tipo == 'entrada': h = 1 elif tipo == 'principal': h = 2 elif tipo == 'sobremesa': h = 3 else: h = 4 v = 0 u = 0 lista2 = [] if g != -2: g+=1 if g == h: s = u = 1 lista1 = linha.split() for i in lista1: if i == comida: v = 1 elif v == 1: v = 0 else: lista2.append(i+' ') lista2.append('\n') if u == 1: arquivo.writelines(lista2) else: arquivo.writelines(linha) arquivo.close()
def read(): lista = [] nome = input() lista.append(nome+' ') cnpj = input() lista.append(cnpj+' ') endereco = input() lista.append(endereco+' ') telefone = input() lista.append(telefone+'\n') return lista
def criar_rest():
restaurante = read()
arquivo = open('dados.txt', 'a')
arquivo.writelines(restaurante)
entrada = input()
precoe = input()
principal = input()
precop = input()
sobremesa = input()
precos = input()
bebida = input()
precob = input()
en = []
en.append(entrada+' ')
en.append(precoe+'\n')
pri = []
pri.append(principal+' ')
pri.append(precop+'\n')
sob = []
sob.append(sobremesa+' ')
sob.append(precos+'\n')
be = []
be.append(bebida+' ')
be.append(precob+'\n')
arquivo.writelines(en)
arquivo.writelines(pri)
arquivo.writelines(sob)
arquivo.writelines(be)
arquivo.close()
def procurar_rest(): nome = input() arquivo = open('dados.txt', 'r') texto = arquivo.readlines() j = 0 for i in texto: lista = i.split() if lista[0] == nome: print(lista) j = 1 break if j == 0: print('Restaurante nao encontrado') arquivo.close()
criar_rest() print("Procure: ") procurar_rest() print("Adicione cardapio: ") add_card() print("Delete cardapio: ") del_card() print("Delete rest: ") delete_rest() </syntaxhighlight>