From 2e5ed5bdf49dd49d47b51b2a2e936f4e135ac1bc Mon Sep 17 00:00:00 2001 From: Adam Jurkiewicz Pythonista Local Date: Fri, 19 Dec 2025 09:33:17 +0100 Subject: [PATCH] r --- dzien_05/klasy_03_tl.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/dzien_05/klasy_03_tl.py b/dzien_05/klasy_03_tl.py index f3720ab..2bd9d6b 100644 --- a/dzien_05/klasy_03_tl.py +++ b/dzien_05/klasy_03_tl.py @@ -1,17 +1,29 @@ class Computer: - def __init__(self): + def __init__(self, info: str, typ: str): print("Startujemy...") # definicja właściwości obiektów tej lasy self.procesor = "CPU at start" self.speed = "5 GHz" self.cpu_speed = 5000 + self.informacja = info + self.typ = typ def __str__(self): return f"To jest {id(self)=}" + + def informacje(self): + if self.cpu_speed < 3000: + text = "- to jest wolny komputer" + else: + text = "- to jest szybki komputer" + return f"Info: {self.informacja} / {text}" - -komputer1 = Computer() -komputer2 = Computer() +# TypeError: +# Computer.__init__() +# missing 1 required positional argument: +# 'info' +komputer1 = Computer("Komputer z lat 90tych", "XT", 1200) +komputer2 = Computer("Inna informacja", "AT") print(komputer1) print('-------------------') @@ -30,4 +42,11 @@ print('-------------------') komputer1.nowe_property = "Jakaś tam" print(dir(komputer1)) print(dir(komputer2)) -print('-------------------') \ No newline at end of file +print('-------------------') + +# print(komputer1.informacje) +# > + +print(komputer1.informacje()) \ No newline at end of file