33 lines
800 B
Python
33 lines
800 B
Python
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)
|