2020-05-26 23:15:49 +02:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
|
2020-05-26 23:15:49 +02:00
|
|
|
class Plant:
|
|
|
|
|
|
|
|
def __init__(self, name, collect=0):
|
|
|
|
super().__init__()
|
2020-06-09 15:28:02 +02:00
|
|
|
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
|
2020-05-26 23:15:49 +02:00
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
# to sie drukuje jak zapytamy o stworzony obiekt
|
2020-05-26 23:15:49 +02:00
|
|
|
def __str__(self):
|
|
|
|
return f'Plant: {self._name}, Soil: {self._soil}, Status: {self.collect()}'
|
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
# metoda abstrakcyjna, kazda roslina ma inny czas rosniecia wiec pass
|
2020-05-26 23:15:49 +02:00
|
|
|
@abstractmethod
|
|
|
|
def collect(self):
|
|
|
|
pass
|
2020-06-09 15:28:02 +02:00
|
|
|
|
2020-05-26 23:15:49 +02:00
|
|
|
@abstractmethod
|
|
|
|
def fertillizing(self):
|
|
|
|
pass
|
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
# pobieramy wspolrzedne roslinki
|
2020-05-26 23:15:49 +02:00
|
|
|
def get_coordinates(self):
|
|
|
|
if self.have_soil():
|
|
|
|
a = self.get_soil()
|
2020-06-09 15:28:02 +02:00
|
|
|
a.get_coordinates(self) # get coordinates jest metoda w glebie
|
2020-05-26 23:15:49 +02:00
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
return self._name
|
|
|
|
|
|
|
|
def get_collect(self):
|
|
|
|
return self._collect
|
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
# dodajemy glebe
|
2020-05-26 23:15:49 +02:00
|
|
|
def add_soil(self, soil):
|
|
|
|
self._soil = soil
|
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
# zwraca czy roslinka znajduje sie w ziemii obecnie - jak nie ma gleby to znaczy ze nie jest zasadzona jeszcze albo już.
|
2020-05-26 23:15:49 +02:00
|
|
|
def have_soil(self):
|
|
|
|
return self._soil is not -1
|
2020-06-09 15:28:02 +02:00
|
|
|
|
|
|
|
# pobieramy jaka ma glebe, gleba tutaj będzie obiektem
|
2020-05-26 23:15:49 +02:00
|
|
|
def get_soil(self):
|
|
|
|
return self._soil
|
|
|
|
|
2020-06-09 15:28:02 +02:00
|
|
|
# to w przypadku jak bedziemy wyciagac z ziemii roslinke
|
2020-05-26 23:15:49 +02:00
|
|
|
def leave_soil(self):
|
|
|
|
if self.have_soil():
|
2020-06-09 15:28:02 +02:00
|
|
|
self._soil = -1
|