81 lines
2.2 KiB
Python
81 lines
2.2 KiB
Python
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):
|
|
self.__horizontal_index = horizontal_index
|
|
self.__vertical_index = vertical_index
|
|
self.__hitch = hitch
|
|
self.__header = header
|
|
self.__fuel_tank = 100
|
|
self.__engineWorking = False
|
|
|
|
@property
|
|
def horizontal_index(self):
|
|
return self.__horizontal_index
|
|
|
|
@horizontal_index.setter
|
|
def horizontal_index(self, horizontal_index):
|
|
if self.__horizontal_index > 1 or self.__horizontal_index < HORIZONTAL_TILES_NUMBER - 1:
|
|
if self.__engineWorking:
|
|
self.__horizontal_index = horizontal_index
|
|
|
|
@property
|
|
def vertical_index(self):
|
|
return self.__vertical_index
|
|
|
|
@vertical_index.setter
|
|
def vertical_index(self, vertical_index):
|
|
if self.__vertical_index > 1 or self.__vertical_index < VERTICAL_TILES_NUMBER - 1:
|
|
if self.__engineWorking:
|
|
self.__vertical_index = vertical_index
|
|
|
|
@property
|
|
def hitch(self):
|
|
return self.__hitch
|
|
|
|
@hitch.setter
|
|
def hitch(self, hitch):
|
|
if hitch == "Tillage unit" or "Crop Trailer" or TractorTrailer or "Nothing":
|
|
self.__hitch = hitch
|
|
|
|
@property
|
|
def fuel_tank(self):
|
|
return self.__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
|
|
if self.__fuel_tank <= 0:
|
|
self.__engineWorking = False
|
|
|
|
@property
|
|
def header(self):
|
|
return self.__header
|
|
|
|
@header.setter
|
|
def header(self, header):
|
|
if header is True or False:
|
|
self.__header = header
|
|
|
|
@property
|
|
def engineWorking(self):
|
|
return self.__engineWorking
|
|
|
|
def turnOnEngine(self):
|
|
if self.__fuel_tank > 0:
|
|
self.__engineWorking = True
|
|
else:
|
|
print("noFuel")
|
|
|
|
def turnOffEngine(self):
|
|
self.__engineWorking = False
|