klasy roślin (zmienione)
This commit is contained in:
parent
8b81d751b9
commit
ab08c46c63
38
Podprojekt_s444426/beetroot_upgrade.py
Normal file
38
Podprojekt_s444426/beetroot_upgrade.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from plant_upgrade import Plant
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class Beetroot(Plant):
|
||||||
|
|
||||||
|
def __init__(self, collect):
|
||||||
|
super().__init__('beetroot', collect)
|
||||||
|
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu
|
||||||
|
|
||||||
|
def add_soil(self, soil):
|
||||||
|
super().add_soil(soil)
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
#zwraca czy zbierać rośline
|
||||||
|
def collect(self):
|
||||||
|
if self.have_soil():
|
||||||
|
self.__growing()
|
||||||
|
if self._collect < 95:
|
||||||
|
return 'False'
|
||||||
|
elif 95 <= self._collect <= 115:
|
||||||
|
return 'True'
|
||||||
|
elif self._collect > 115:
|
||||||
|
return 'Delete'
|
||||||
|
|
||||||
|
#zwraca czy nawozić
|
||||||
|
def fertillizing(self):
|
||||||
|
if 35 <= self._collect <= 50:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
|
||||||
|
def __growing(self):
|
||||||
|
checktime = datetime.now()
|
||||||
|
delta = checktime - self._starttime
|
||||||
|
a = delta // 40
|
||||||
|
# self._collect += a
|
||||||
|
self._starttime = checktime
|
38
Podprojekt_s444426/cabbage_upgrade.py
Normal file
38
Podprojekt_s444426/cabbage_upgrade.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from plant_upgrade import Plant
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class Cabbage(Plant):
|
||||||
|
|
||||||
|
def __init__(self, collect):
|
||||||
|
super().__init__('cabbage', collect)
|
||||||
|
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu
|
||||||
|
|
||||||
|
def add_soil(self, soil):
|
||||||
|
super().add_soil(soil)
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
#zwraca czy zbierać rośline
|
||||||
|
def collect(self):
|
||||||
|
if self.have_soil():
|
||||||
|
self.__growing()
|
||||||
|
if self._collect < 85:
|
||||||
|
return 'False'
|
||||||
|
elif 85 <= self._collect <= 100:
|
||||||
|
return 'True'
|
||||||
|
elif self._collect > 100:
|
||||||
|
return 'Delete'
|
||||||
|
|
||||||
|
#zwraca czy nawozić
|
||||||
|
def fertillizing(self):
|
||||||
|
if 30 <= self._collect <= 45:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
|
||||||
|
def __growing(self):
|
||||||
|
checktime = datetime.now()
|
||||||
|
delta = checktime - self._starttime
|
||||||
|
a = delta // 70
|
||||||
|
#self._collect += a
|
||||||
|
self._starttime = checktime
|
38
Podprojekt_s444426/carrot_upgrade.py
Normal file
38
Podprojekt_s444426/carrot_upgrade.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from plant_upgrade import Plant
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class Carrot(Plant):
|
||||||
|
|
||||||
|
def __init__(self, collect):
|
||||||
|
super().__init__('carrot', collect)
|
||||||
|
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu
|
||||||
|
|
||||||
|
def add_soil(self, soil):
|
||||||
|
super().add_soil(soil)
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
#zwraca czy zbierać rośline
|
||||||
|
def collect(self):
|
||||||
|
if self.have_soil():
|
||||||
|
self.__growing()
|
||||||
|
if self._collect < 90:
|
||||||
|
return 'False'
|
||||||
|
elif 90 <= self._collect <= 105:
|
||||||
|
return 'True'
|
||||||
|
elif self._collect > 105:
|
||||||
|
return 'Delete'
|
||||||
|
|
||||||
|
#zwraca czy nawozić
|
||||||
|
def fertillizing(self):
|
||||||
|
if 30 <= self._collect <= 50:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
|
||||||
|
def __growing(self):
|
||||||
|
checktime = datetime.now()
|
||||||
|
delta = checktime - self._starttime
|
||||||
|
a = delta // 60
|
||||||
|
# self._collect += a
|
||||||
|
self._starttime = checktime
|
71
Podprojekt_s444426/plant_upgrade.py
Normal file
71
Podprojekt_s444426/plant_upgrade.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
class Plant:
|
||||||
|
|
||||||
|
#tworzymy jakas rosline co ma nazwe i id. ID powiedzmy ze buraki beda mialy 1, marchewki 2 itd. gleby powiedzmy tez damy 4 i beda mialy id 5-8
|
||||||
|
def __init__(self, name, collect=0):
|
||||||
|
super().__init__()
|
||||||
|
self._soil = -1 #jak tworzymy rosline to nie bedzie ona miala gleby
|
||||||
|
self._name = name #to nazwa rosliny będzie np. burak1
|
||||||
|
#self._id = ID #id rosliny buraki bedą mialy 1, i po tym inne obiekty beda rozpoznawac ten obiekt
|
||||||
|
self._collect = collect #nowa roslina jest w 0% dojrzala
|
||||||
|
|
||||||
|
#to jest jakbysmy usuneli obiekt. zabezpieczenie, zeby gleba pozniej byla wolna
|
||||||
|
# def __del__(self):
|
||||||
|
# self.leave_soil()
|
||||||
|
|
||||||
|
#to sie drukuje jak zapytamy o stworzony obiekt
|
||||||
|
def __str__(self):
|
||||||
|
return f'Plant: {self._name}, Soil: {self._soil}, Status: {self.collect()}'
|
||||||
|
|
||||||
|
#metoda abstrakcyjna, kazda roslina ma inny czas rosniecia wiec pass
|
||||||
|
@abstractmethod
|
||||||
|
def collect(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def fertillizing(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def growing(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
#pobieramy wspolrzedne roslinki
|
||||||
|
def get_coordinates(self):
|
||||||
|
if self.have_soil():
|
||||||
|
a = self.get_soil()
|
||||||
|
a.get_coordinates(self) #get coordinates jest metoda w glebie
|
||||||
|
|
||||||
|
#pobieramy id roślinki
|
||||||
|
def get_id(self):
|
||||||
|
return self._id
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
def get_collect(self):
|
||||||
|
return self._collect
|
||||||
|
|
||||||
|
#dodajemy glebe
|
||||||
|
def add_soil(self, soil):
|
||||||
|
self._soil = soil
|
||||||
|
|
||||||
|
#zwraca czy roslinka znajduje sie w ziemii obecnie - jak nie ma gleby to znaczy ze nie jest zasadzona jeszcze albo już.
|
||||||
|
def have_soil(self):
|
||||||
|
return self._soil is not -1
|
||||||
|
|
||||||
|
#pobieramy jaka ma glebe, gleba tutaj będzie obiektem
|
||||||
|
def get_soil(self):
|
||||||
|
return self._soil
|
||||||
|
|
||||||
|
#to w przypadku jak bedziemy wyciagac z ziemii roslinke
|
||||||
|
def leave_soil(self):
|
||||||
|
if self.have_soil():
|
||||||
|
# a = self.get_soil()
|
||||||
|
# a.plant_remove() #to bedzie metoda w klasie Soil, bedzie usuwac roslinke z gleby
|
||||||
|
self._soil = -1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
38
Podprojekt_s444426/pumpkin_upgrade.py
Normal file
38
Podprojekt_s444426/pumpkin_upgrade.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from plant_upgrade import Plant
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class Pumpkin(Plant):
|
||||||
|
|
||||||
|
def __init__(self, collect):
|
||||||
|
super().__init__('pumpkin', collect)
|
||||||
|
self._wasFertilized = False #roslina nie byla nawozona przy tworzeniu
|
||||||
|
|
||||||
|
def add_soil(self, soil):
|
||||||
|
super().add_soil(soil)
|
||||||
|
self._starttime = datetime.now()
|
||||||
|
|
||||||
|
#zwraca czy zbierać rośline
|
||||||
|
def collect(self):
|
||||||
|
if self.have_soil():
|
||||||
|
self.__growing()
|
||||||
|
if self._collect < 90:
|
||||||
|
return 'False'
|
||||||
|
elif 90 <= self._collect <= 110:
|
||||||
|
return 'True'
|
||||||
|
elif self._collect > 110:
|
||||||
|
return 'Delete'
|
||||||
|
|
||||||
|
#zwraca czy nawozić
|
||||||
|
def fertillizing(self):
|
||||||
|
if 20 <= self._collect <= 45:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
#każde iles czasu zwieksza wzrost rosliny, wywolywana w momencie sprawdzania czy roslina jest gotowa do zbiorow
|
||||||
|
def __growing(self):
|
||||||
|
checktime = datetime.now()
|
||||||
|
delta = checktime - self._starttime
|
||||||
|
a = delta // 50
|
||||||
|
# self._collect += a
|
||||||
|
self._starttime = checktime
|
Loading…
Reference in New Issue
Block a user