adding all files done so far
This commit is contained in:
32
learning/property/property2.py
Normal file
32
learning/property/property2.py
Normal file
@@ -0,0 +1,32 @@
|
||||
class Robot:
|
||||
|
||||
def __init__(self, name, build_year, lk=0.5,
|
||||
lp=0.5):
|
||||
self.name = name
|
||||
self.build_year = build_year
|
||||
self.__potential_physical = lk
|
||||
self.__potential_psychic = lp
|
||||
|
||||
@property
|
||||
def condition(self):
|
||||
s = self.__potential_physical + self.__potential_psychic
|
||||
if s <= -1:
|
||||
return "I feel miserable!"
|
||||
elif s <= 0:
|
||||
return "I feel bad!"
|
||||
elif s <= 0.5:
|
||||
return "Could be worse!"
|
||||
elif s <= 1:
|
||||
return "Seems to be okay!"
|
||||
else:
|
||||
return "Great!"
|
||||
|
||||
def printer(self):
|
||||
return self.condition
|
||||
|
||||
def __get__(self, instance, owner):
|
||||
return 'get'
|
||||
|
||||
|
||||
x = Robot("Marvin", 1979, 0.2, 0.4)
|
||||
y = Robot("Caliban", 1993, -0.4, 0.3)
|
||||
Reference in New Issue
Block a user