From 162c051b09f512acea14f308563a0939f4c7158e Mon Sep 17 00:00:00 2001 From: v7eZ3t Date: Mon, 29 Mar 2021 01:24:28 +0200 Subject: [PATCH] v. 1.06 --- Tractor.py | 49 ++++++++++++++++++++++++++++++++----------------- TractorLoad.py | 12 ++++++++++++ 2 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 TractorLoad.py diff --git a/Tractor.py b/Tractor.py index fecf20d..fea1ff6 100644 --- a/Tractor.py +++ b/Tractor.py @@ -1,10 +1,14 @@ +from Main.TractorLoad import TractorTrailer +from Main.constants import HORIZONTAL_TILES_NUMBER, VERTICAL_TILES_NUMBER + + class Tractor: - def __init__(self, horizontal_index, vertical_index, hitch, header, fuel_tank): - self.horizontal_index = horizontal_index - self.vertical_index = vertical_index - self.hitch = hitch - self.header = header - self.fuel_tank = fuel_tank + def __init__(self, __horizontal_index, __vertical_index, __hitch, __header, __fuel_tank): + self.__horizontal_index = __horizontal_index + self.__vertical_index = __vertical_index + self.__hitch = __hitch + self.__header = __header + self.__fuel_tank = __fuel_tank @property def horizontal_index(self): @@ -12,36 +16,47 @@ class Tractor: @horizontal_index.setter def horizontal_index(self, horizontal_index): - self.__horizontal_index = horizontal_index - + if self.__horizontal_index < 1 or self.__horizontal_index >= HORIZONTAL_TILES_NUMBER - 1: + self.__horizontal_index = horizontal_index + @property def vertical_index(self): return self.__vertical_index @vertical_index.setter def vertical_index(self, vertical_index): - self.__vertical_index = vertical_index - + if self.__vertical_index < 1 or self.__vertical_index >= VERTICAL_TILES_NUMBER - 1: + self.__vertical_index = vertical_index + @property def hitch(self): return self.__hitch @hitch.setter def hitch(self, hitch): - self.__hitch = hitch - + if hitch is "Tillage unit" or "Crop Trailer" or TractorTrailer or "Nothing": + self.__hitch = hitch + @property def fuel_tank(self): return self.__fuel_tank - @fuel_tank.setter - def fuel_tank(self, fuel_tank): - self.__fuel_tank = fuel_tank - + def __fuel_tank(self, fuel_tank): + if 0 < fuel_tank < 100: + self.__fuel_tank = fuel_tank + + def fill_tank(self): + self.__fuel_tank(100) + + def reduce_fuel(self): + if 0 < self.fuel_tank < 100: + self.__fuel_tank = self.__fuel_tank - 1 + @property def header(self): return self.__header @header.setter def header(self, header): - self.__header = header \ No newline at end of file + if header is True or False: + self.__header = header diff --git a/TractorLoad.py b/TractorLoad.py new file mode 100644 index 0000000..93245bc --- /dev/null +++ b/TractorLoad.py @@ -0,0 +1,12 @@ +class TractorTrailer: + def __init__(self, __load): + self.__load = __load + + @property + def load(self): + return self.__load + + @load.setter + def load(self, load): + if self.__load is "Fertilizer" or "Seeds" or "Water": + self.__load = load