k
This commit is contained in:
34
dzien_05/klasy_03_tl copy.py
Normal file
34
dzien_05/klasy_03_tl copy.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from random import randint, choice
|
||||||
|
|
||||||
|
typy = ("XT8", "IBM PS/2", "AT206", "AT386", "AT386DX",
|
||||||
|
"Fijitsu", "Dell", "DEC", "Compaq",
|
||||||
|
"VAX OpemVMS", "IBM VM/360", "Z Series")
|
||||||
|
|
||||||
|
komputery = []
|
||||||
|
|
||||||
|
class Computer:
|
||||||
|
def __init__(self, info: str, typ: str, speed: int):
|
||||||
|
print("Startujemy...")
|
||||||
|
# definicja właściwości obiektów tej lasy
|
||||||
|
self.procesor = "CPU at start"
|
||||||
|
self.speed = "5 GHz"
|
||||||
|
self.cpu_speed = speed
|
||||||
|
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}"
|
||||||
|
|
||||||
|
for _ in range(5):
|
||||||
|
c_typ = choice(typy)
|
||||||
|
c_info = f"informacja o -> {c_typ}"
|
||||||
|
c_speed = randint(600, 6000)
|
||||||
|
comp = Computer(c_info, c_typ, c_speed)
|
||||||
|
komputery.append(comp)
|
||||||
Reference in New Issue
Block a user