plan na czwartek
This commit is contained in:
47
dzien_04/przyklady/klasy_03_zadanie.py
Normal file
47
dzien_04/przyklady/klasy_03_zadanie.py
Normal file
@@ -0,0 +1,47 @@
|
||||
class Computer:
|
||||
def __init__(self):
|
||||
print("Startujemy...")
|
||||
# definicja właściwości obiektów tej lasy
|
||||
self.procesor = "CPU at start"
|
||||
self.speed = "5 GHz"
|
||||
self.cpu_speed = 5000
|
||||
|
||||
def informacje(self):
|
||||
print(f"Mój komputer ma procesor {self.procesor}")
|
||||
print(f"o prędkości {self.speed}")
|
||||
return None
|
||||
|
||||
# utówrz metodę szybki i zwróć w niej True gdy self.cpu_speed>3000
|
||||
# inaczej False - sprawdź, przetestuj, ustaw 1 obiekt na cpu_speed 1200
|
||||
|
||||
def szybki(self):
|
||||
# return True if self.cpu_speed > 3000 else False
|
||||
if self.cpu_speed> 3000:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
komputer1 = Computer()
|
||||
komputer2 = Computer()
|
||||
|
||||
print(komputer1)
|
||||
print(dir(komputer1))
|
||||
print(dir(komputer2))
|
||||
print(komputer1.procesor)
|
||||
print(komputer2.procesor)
|
||||
|
||||
komputer1.procesor = "AMD M6"
|
||||
print('-------------------')
|
||||
print(komputer1.procesor)
|
||||
print(komputer2.procesor)
|
||||
|
||||
print('-------------------')
|
||||
komputer2.speed = "3,3 GHz"
|
||||
komputer1.informacje()
|
||||
komputer2.informacje()
|
||||
|
||||
print(komputer1.szybki())
|
||||
print(komputer2.szybki())
|
||||
komputer1.cpu_speed = 1200
|
||||
print(komputer1.szybki())
|
||||
print(komputer2.szybki())
|
||||
Reference in New Issue
Block a user