From b7b7a509df8b3282e7c654674625ce5b5116ce0c Mon Sep 17 00:00:00 2001 From: s444426 Date: Tue, 9 Jun 2020 15:28:02 +0200 Subject: [PATCH] plant, soil upgrade --- Podprojekt_s444426/beetroot_upgrade.py | 24 ++++--------- Podprojekt_s444426/cabbage_upgrade.py | 24 ++++--------- Podprojekt_s444426/carrot_upgrade.py | 24 ++++--------- Podprojekt_s444426/plant_ID3.py | 5 ++- Podprojekt_s444426/plant_upgrade.py | 49 ++++++++------------------ Podprojekt_s444426/pumpkin_upgrade.py | 24 ++++--------- Podprojekt_s444426/soil_upgrade.py | 38 ++++---------------- 7 files changed, 48 insertions(+), 140 deletions(-) diff --git a/Podprojekt_s444426/beetroot_upgrade.py b/Podprojekt_s444426/beetroot_upgrade.py index 7154a44..479c930 100644 --- a/Podprojekt_s444426/beetroot_upgrade.py +++ b/Podprojekt_s444426/beetroot_upgrade.py @@ -1,20 +1,16 @@ 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 + 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 + # 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: @@ -22,17 +18,9 @@ class Beetroot(Plant): elif self._collect > 115: return 'Delete' - #zwraca czy nawozić + # 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 + return False \ No newline at end of file diff --git a/Podprojekt_s444426/cabbage_upgrade.py b/Podprojekt_s444426/cabbage_upgrade.py index 6f0c36a..8947b6c 100644 --- a/Podprojekt_s444426/cabbage_upgrade.py +++ b/Podprojekt_s444426/cabbage_upgrade.py @@ -1,20 +1,16 @@ 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 + 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 + # 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: @@ -22,17 +18,9 @@ class Cabbage(Plant): elif self._collect > 100: return 'Delete' - #zwraca czy nawozić + # 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 + return False \ No newline at end of file diff --git a/Podprojekt_s444426/carrot_upgrade.py b/Podprojekt_s444426/carrot_upgrade.py index e979c21..4de2ea5 100644 --- a/Podprojekt_s444426/carrot_upgrade.py +++ b/Podprojekt_s444426/carrot_upgrade.py @@ -1,20 +1,16 @@ 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 + 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 + # 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: @@ -22,17 +18,9 @@ class Carrot(Plant): elif self._collect > 105: return 'Delete' - #zwraca czy nawozić + # 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 + return False \ No newline at end of file diff --git a/Podprojekt_s444426/plant_ID3.py b/Podprojekt_s444426/plant_ID3.py index 436cdae..cafcf48 100644 --- a/Podprojekt_s444426/plant_ID3.py +++ b/Podprojekt_s444426/plant_ID3.py @@ -26,7 +26,7 @@ def decide_to_plant(soil): # Roślina jest gotowa do zbioru lub ziemia jest wolna predicted = predict_data(data) - # grow_a_plant(soil,predicted[0][0]) + grow_a_plant(soil, predicted[0][0]) return predicted @@ -34,7 +34,6 @@ def decide_to_plant(soil): def grow_a_plant(soil, plant_name): plant = Plant(plant_name) soil.add_plant(plant) - print(soil) def get_info(soil): @@ -95,4 +94,4 @@ for soil in all_soil: result.append([soil.get_pH(), soil.get_dry_level(), plant, collect, p[0]]) result = pd.DataFrame(data=result, columns=['pH', 'dry level', 'plant', 'ripe', 'prediction']) -print(result) +#print(result) \ No newline at end of file diff --git a/Podprojekt_s444426/plant_upgrade.py b/Podprojekt_s444426/plant_upgrade.py index 7c6db81..578581c 100644 --- a/Podprojekt_s444426/plant_upgrade.py +++ b/Podprojekt_s444426/plant_upgrade.py @@ -1,45 +1,32 @@ 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 + self._soil = -1 # jak tworzymy rosline to nie bedzie ona miala gleby + self._name = name # to nazwa rosliny będzie np. burak + self._collect = collect # nowa roslina jest domyślnie 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 + # 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 + # 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 + # 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 + a.get_coordinates(self) # get coordinates jest metoda w glebie def get_name(self): return self._name @@ -47,25 +34,19 @@ class Plant: def get_collect(self): return self._collect - #dodajemy glebe + # 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ż. + # 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 + + # 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 + # 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 - - - - + self._soil = -1 \ No newline at end of file diff --git a/Podprojekt_s444426/pumpkin_upgrade.py b/Podprojekt_s444426/pumpkin_upgrade.py index ae4cb98..456d828 100644 --- a/Podprojekt_s444426/pumpkin_upgrade.py +++ b/Podprojekt_s444426/pumpkin_upgrade.py @@ -1,20 +1,16 @@ 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 + 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 + # 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: @@ -22,17 +18,9 @@ class Pumpkin(Plant): elif self._collect > 110: return 'Delete' - #zwraca czy nawozić + # 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 + return False \ No newline at end of file diff --git a/Podprojekt_s444426/soil_upgrade.py b/Podprojekt_s444426/soil_upgrade.py index 76045bc..0cd966b 100644 --- a/Podprojekt_s444426/soil_upgrade.py +++ b/Podprojekt_s444426/soil_upgrade.py @@ -1,34 +1,19 @@ from datetime import datetime + class Soil: def __init__(self, pH, dry): super().__init__() - #self._id = ID - #self._x = x - #self._y = y - self._plant = -1 #nowa gleba nie ma roślinki - self._dry = dry #procent wysuszenia gleby, tworząc nową jest nawodniona w 100% + self._plant = -1 # nowa gleba nie ma roślinki + self._dry = dry # procent wysuszenia gleby, tworząc nową jest nawodniona w 100% self._pH = pH - self._starttime = datetime.now() - -# def __del__(self): -# self.plant_remove() def __str__(self): if self.have_plant(): return f'pH={self._pH}, dry level={self._dry}, plant={self.get_plant().get_name()}' else: return f'soil: pH={self._pH}, dry level={self._dry}, plant=none' - #return f'{self._x}, {self._y}), Plant: {self._plant}' - - # współrzędne pola - def get_coordinates(self): - return self._x, self._y - - # id gleby - def get_id(self): - return self._id # zasadzenie roślinki def add_plant(self, plant): @@ -39,7 +24,7 @@ class Soil: # zwraca czy w ziemi znajduje się roślinka def have_plant(self): return self._plant != -1 - + # zwraca roślinkę znajdującą się w ziemii def get_plant(self): return self._plant @@ -50,7 +35,7 @@ class Soil: def get_dry_level(self): return self._dry - #sprawdza w ilu procentach ziemia jest sucha + # sprawdza w ilu procentach ziemia jest sucha def is_dry(self): self.__drying() if self._dry < 30: @@ -60,19 +45,10 @@ class Soil: else: return 'True' - #metoda wysuszajaca ziemie. dodaje wysuszenie do ziemi, wywolywana w momencie sprawdzania czy ziemia jest sucha - def __drying(self): - checktime = datetime.now() - delta = checktime - self._starttime - a = delta //60 - self._dry += a - self._starttime = checktime - self.__is_dry() - - # usuwa roślinkę z ziemi i ją zwraca def plant_remove(self): if self.have_plant(): a = self.get_plant() a.leave_soil() - self._plant = -1 \ No newline at end of file + self._plant = -1 + return a \ No newline at end of file