From ab08c46c6395fe8736b650fdf9111c44384e6b90 Mon Sep 17 00:00:00 2001 From: Agata Lenz Date: Tue, 26 May 2020 21:15:49 +0000 Subject: [PATCH] =?UTF-8?q?klasy=20ro=C5=9Blin=20(zmienione)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Podprojekt_s444426/beetroot_upgrade.py | 38 ++++++++++++++ Podprojekt_s444426/cabbage_upgrade.py | 38 ++++++++++++++ Podprojekt_s444426/carrot_upgrade.py | 38 ++++++++++++++ Podprojekt_s444426/plant_upgrade.py | 71 ++++++++++++++++++++++++++ Podprojekt_s444426/pumpkin_upgrade.py | 38 ++++++++++++++ 5 files changed, 223 insertions(+) create mode 100644 Podprojekt_s444426/beetroot_upgrade.py create mode 100644 Podprojekt_s444426/cabbage_upgrade.py create mode 100644 Podprojekt_s444426/carrot_upgrade.py create mode 100644 Podprojekt_s444426/plant_upgrade.py create mode 100644 Podprojekt_s444426/pumpkin_upgrade.py diff --git a/Podprojekt_s444426/beetroot_upgrade.py b/Podprojekt_s444426/beetroot_upgrade.py new file mode 100644 index 0000000..7154a44 --- /dev/null +++ b/Podprojekt_s444426/beetroot_upgrade.py @@ -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 diff --git a/Podprojekt_s444426/cabbage_upgrade.py b/Podprojekt_s444426/cabbage_upgrade.py new file mode 100644 index 0000000..6f0c36a --- /dev/null +++ b/Podprojekt_s444426/cabbage_upgrade.py @@ -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 diff --git a/Podprojekt_s444426/carrot_upgrade.py b/Podprojekt_s444426/carrot_upgrade.py new file mode 100644 index 0000000..e979c21 --- /dev/null +++ b/Podprojekt_s444426/carrot_upgrade.py @@ -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 diff --git a/Podprojekt_s444426/plant_upgrade.py b/Podprojekt_s444426/plant_upgrade.py new file mode 100644 index 0000000..7c6db81 --- /dev/null +++ b/Podprojekt_s444426/plant_upgrade.py @@ -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 + + + + diff --git a/Podprojekt_s444426/pumpkin_upgrade.py b/Podprojekt_s444426/pumpkin_upgrade.py new file mode 100644 index 0000000..ae4cb98 --- /dev/null +++ b/Podprojekt_s444426/pumpkin_upgrade.py @@ -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