Commit 8ba5f6e9 by Patryk Czarnik

klasa Product

parent 4c0e7f67
...@@ -7,7 +7,11 @@ class Product: ...@@ -7,7 +7,11 @@ class Product:
def print_info(self): def print_info(self):
print(f'Produkt "{self.nazwa}", id: {self.id}, cena: {self.cena} PLN') print(f'Produkt "{self.nazwa}", id: {self.id}, cena: {self.cena} PLN')
def __str__(self):
return f'Produkt nr {self.id}: {self.nazwa} za {self.cena}'
p = Product(1, 'Woda', 10.99) p = Product(1, 'Woda', 10.99)
p.print_info() p.print_info()
print('p:', p) print(p)
print(f'Mam w zmiennej coś: {p}. Koniec tematu.')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment