This is the main program (field_class) which is the basis of all the farm and which you open to access and manage your farm. It calls upon all the other programs such as cow_class and wheat_class which are kept in the same folder to fill the farm:
from potato_class import * from wheat_class import * from sheep_class import * from cow_class import * class Field: """simulation of the farm""" def __init__(self,max_animals,max_crops): self._crops = [] self._animals = [] self._max_animals = max_animals self._max_crops = max_crops def plant_crop(self, crop): if len(self._cropss) < self._max_crops: self._crops.append(crop) return True else: return False def add_animal(self, animal): if len(self._animals) < self._max_animals: self._animals.append(animal) return True else: return False def harvest_crop(self,position): return self._crops.pop(position) def remove_animal def main(): new_field = Field(5,2) print(new_field._crops) print(new_field._animals) print(new_field._max_animals) print(new_field._max_crops) new_field.plant_crop(Wheat()) new_field.add_animal(Sheep("le sheep")) print(new_field._crops) print(new_field._animals) if __name__ == '__main__': main()
This is an example of one off the classes that the main program calls upon for information about either a crop or an animal which can populate the farm. Since all of these are similar in terms of code used i will only use one as an example:
from crop_class import * class Potato(Crop): """A POTATO CROP""" #constructor def __init__(self): #call the parent class constructor with default values for potato #growth rate = 1; light need = 3; water need = 6 super().__init__(1,3,6) self._type = "potato" #override grow method of subclass def grow(self,light,water): if light >= self._light_need and water >= self._water_need: if self._status == "Seedling" and water > self._water_need: self._growth += self._growth_rate * 1.5 elif self._status == "Young" and water > self._water_need: self._growth += self._growth_rate * 1.25 else: self._growth += self._growth_rate #increatment day growing self._days_growing += 1 #Update the status self._update_status() def main(): #create a new potato crop potato_crop = Potato() print(potato_crop.report()) #manually grow the crop manual_grow(potato_crop) print(potato_crop.report()) if __name__ == "__main__": main()
from potato_class import * from wheat_class import * from sheep_class import * from cow_class import * class Field: """simulation of the farm""" def __init__(self,max_animals,max_crops): self._crops = [] self._animals = [] self._max_animals = max_animals self._max_crops = max_crops def plant_crop(self, crop): if len(self._cropss) < self._max_crops: self._crops.append(crop) return True else: return False def add_animal(self, animal): if len(self._animals) < self._max_animals: self._animals.append(animal) return True else: return False def harvest_crop(self,position): return self._crops.pop(position) def remove_animal def main(): new_field = Field(5,2) print(new_field._crops) print(new_field._animals) print(new_field._max_animals) print(new_field._max_crops) new_field.plant_crop(Wheat()) new_field.add_animal(Sheep("le sheep")) print(new_field._crops) print(new_field._animals) if __name__ == '__main__': main()
This is an example of one off the classes that the main program calls upon for information about either a crop or an animal which can populate the farm. Since all of these are similar in terms of code used i will only use one as an example:
from crop_class import * class Potato(Crop): """A POTATO CROP""" #constructor def __init__(self): #call the parent class constructor with default values for potato #growth rate = 1; light need = 3; water need = 6 super().__init__(1,3,6) self._type = "potato" #override grow method of subclass def grow(self,light,water): if light >= self._light_need and water >= self._water_need: if self._status == "Seedling" and water > self._water_need: self._growth += self._growth_rate * 1.5 elif self._status == "Young" and water > self._water_need: self._growth += self._growth_rate * 1.25 else: self._growth += self._growth_rate #increatment day growing self._days_growing += 1 #Update the status self._update_status() def main(): #create a new potato crop potato_crop = Potato() print(potato_crop.report()) #manually grow the crop manual_grow(potato_crop) print(potato_crop.report()) if __name__ == "__main__": main()
I hope everyone is doing well. I have some news to share today....In the next week I am moving to NOLA and hoping this new journey will put me back into the attitude that change is good. So much to do and not enough time to do it. I am so thankful for all of the wonderful people in my life (including Pedro Jerome) a loan lender that support me at all times I am excited and also worried my life has been such a downer for so long that getting out of it has been hard but I do really feel that this change is going to be the best thing I need right now and I have hopes that all good things do come to those that wait.
ReplyDeleteI'm thanking a loan lender who helped me with a loan of 1 millions dollars to boost up my business once again at the rate of 2% annual return which is so wonderful and I would like anyone stuck in financial situation to reach out on Pedro the loan lender on pedroloanss@gmail.com for a loan assistance.
So please keep me in your thoughts and thanks to this blog I can at least keep in contact with all of you.