przyrost1

This commit is contained in:
Agata Lenz 2020-04-07 18:46:09 +00:00
parent 2a0740f79c
commit 13bea07e02

View File

@ -1,38 +1,38 @@
from plant import Plant from plant import Plant
from datetime import datetime from datetime import datetime
class Cabbage(Plant): class Cabbage(Plant):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu
def add_soil(self, soil): def add_soil(self, soil):
super().add_soil() super().add_soil()
self._starttime = datetime.now() self._starttime = datetime.now()
#zwraca czy zbierać rośline #zwraca czy zbierać rośline
def collect(self): def collect(self):
if self.have_soil(): if self.have_soil():
self.__growing() self.__growing()
if self._collect < 85: if self._collect < 85:
return 'False' return 'False'
elif 85 <= self._collect <= 100: elif 85 <= self._collect <= 100:
return 'True' return 'True'
elif self._collect > 100: elif self._collect > 100:
return 'Delete' return 'Delete'
#zwraca czy nawozić #zwraca czy nawozić
def fertillizing(self): def fertillizing(self):
if 30 <= self._collect <= 45: if 30 <= self._collect <= 45:
return True return True
else: else:
return False return False
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow #każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
def __growing(self): def __growing(self):
checktime = datetime.now() checktime = datetime.now()
delta = checktime - self._starttime delta = checktime - self._starttime
a = delta // 70 a = delta // 70
self._collect += a self._collect += a
self._starttime = checktime self._starttime = checktime