forked from NathanLuis/Poo-Trabalho
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
o codigo da leitura baseado no que o professor deu em sala e no que Natan fez da escrita
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class Produto: | ||
def __init__(self, codigo, nome, preco, validade): | ||
self.nome = nome | ||
self.preco = preco | ||
self.codigo = codigo | ||
self.validade = validade | ||
|
||
estoque = [] | ||
|
||
with open("txt_frutas.txt", "r") as arquivo: | ||
for linha in arquivo: | ||
print(linha) | ||
linha_sep = linha.split(";") | ||
print(linha_sep) | ||
# codigo | ||
print(linha_sep[0]) | ||
# nome | ||
print(linha_sep[1]) | ||
#preco | ||
print(linha_sep[2]) | ||
#validade | ||
print(linha_sep(3)) | ||
# adicionar ao estoque | ||
Produto = Produto(linha_sep[0], linha_sep[3]) | ||
estoque.append(Produto) | ||
|
||
print("\n\n----") | ||
print(estoque) | ||
for f in estoque: | ||
print(f.codigo) | ||
print(f.nome) | ||
print(f.preco) | ||
print(f.validade) |