Example #1
0
 def Choice(self, p, life):
     choice = ToolBox.InputAny("Choose an option: ")
     if choice == "1":
         loopH: bool = True
         while loopH:
             SubMenuHabitat()
             loopH = SubChoiceHabitat(p)
     elif choice == "2":  # Animals submenu
         loopA: bool = True
         while loopA:
             SubMenuAnimal()
             loopA = SubChoiceAnimal(p)
     elif choice == "3":  # Simulation
         cycleTime: int = ToolBox.InputInt("The cycles in miliseconds: ")
         life.LifeCycle(p, cycleTime)
     elif choice == "4":  # Serialization
         p.arkOne.SerializeMyList()
         ToolBox.WriteLineGreen("The Serialization has completed.")
         os.Sleep(1500)
     elif choice == "5":  # Deserialization
         try:
             p.arkOne.DeSerializeMyList()
             ToolBox.WriteLineGreen("The DeSerialization has completed.")
         except FileNotExistException:
             ToolBox.WriteLineRed("The file not exist!")
         time.sleep(1500)
     elif choice == "6":  # Statistics submenu
         loopS: bool = True
         while loopS:
             SubMenuStatistics()
             loopS = SubChoiceStatistics(p)
     elif choice == "7":
         os.system("Clear")
         #StreamReader streamReader = new StreamReader("Readme.md")
         #while not streamReader.EndOfStream:
         #    print(streamReader.ReadLine())
         ToolBox.InputAny("Press any key to continue...")
         return True
     elif choice == "0":  # Exit program
         ToolBox.WriteLineGreen(
             "Thank you for using our service! Have a nice day citizen!")
         return False
     else:
         ToolBox.WriteLineRed("Wrong option!")
         return True
Example #2
0
 def SubChoiceAnimal(self, p):
     choice = ToolBox.InputAny("Choose an option: ")
     print()
     if choice == "1":  # Adding new animals
         typeo: str = ""
         speciesName = ToolBox.InputAny("What is the species?: ")
         habitatName = ToolBox.InputAny(
             "What is the optimal habitat zone?: ")
         while True:
             typeo = ToolBox.InputAny(
                 "What kind of animal is this? (herbivore, carnivore, omnivore): "
             )
             if typeo.ToLower() == "herbivore" or typeo.ToLower(
             ) == "carnivore" or typeo.ToLower() == "omnivore":
                 break
         specimen: int = ToolBox.InputInt("How many animals arrived?: ")
         try:
             for count in range(specimen):
                 p.arkOne.AddNewAnimal(speciesName, type, habitatName)
         except HabitatNotExistException:
             ToolBox.WriteLineRed(
                 "This Habitat is not exist. You should build it first!")
             time.Sleep(1500)
     elif choice == "2":  #Listing an animal
         animaL: Animal
         try:
             animaL = p.arkOne.FindAnimal(
                 ToolBox.InputAny("What is the ID of the animal?: "))
             print("The animal ID is: " + animaL.OwnName)
             print("The animal species is: " + animaL.SpeciesName)
             print("Required energy: " + animaL.ReqEnergyUnit)
             print("Required heat: " + animaL.ReqHeatUnit)
             print("Required oxigen: " + animaL.ReqOxigenUnit)
             print("Required water: " + animaL.ReqWaterUnit)
             print("Required food: " + animaL.ReqFoodUnit)
         except AnimalNotExistException:
             ToolBox.WriteLineRed("There is no such animal...")
         ToolBox.InputAny("Press any key to continue...")
     elif choice == "3":  #Listing all animal
         for habitat in p.arkOne.GetHabitats():
             ToolBox.WriteLineBlue(habitat.HabitatName)
             for animal in habitat.AnimalList:
                 print("ID: " + animal.OwnName.PadRight(4))
                 print(" " + animal.SpeciesName.PadRight(15))
                 print(" RE: " + animal.ReqEnergyUnit)
                 print(" RH: " + animal.ReqHeatUnit)
                 print(" RO: " + animal.ReqOxigenUnit)
                 print(" RW: " + animal.ReqWaterUnit)
                 print(" RF: " + animal.ReqFoodUnit)
         print("Press any key to continue...")
         ToolBox.InputAny()
     elif choice == "4":  #Update an animal
         try:
             animaL = p.arkOne.FindAnimal(
                 ToolBox.InputAny("What is the ID of the animal?: "))
             print("The animal ID is: " + animaL.OwnName)
             print("The animal species is: " + animaL.SpeciesName)
             print("Required energy: " + animaL.ReqEnergyUnit)
             print("Required heat: " + animaL.ReqHeatUnit)
             print("Required oxigen: " + animaL.ReqOxigenUnit)
             print("Required water: " + animaL.ReqWaterUnit)
             print("Required food: " + animaL.ReqFoodUnit)
             print()
             ToolBox.WriteLineRed(
                 "The parameters should be between 1 and 4")
             print()
             animaL.ReqEnergyUnit = ToolBox.InputIntBetween(
                 "New required energy?: ", 1, 4)
             animaL.ReqHeatUnit = ToolBox.InputIntBetween(
                 "New required heat ?: ", 1, 4)
             animaL.ReqOxigenUnit = ToolBox.InputIntBetween(
                 "New required oxigen?: ", 1, 4)
             animaL.ReqWaterUnit = ToolBox.InputIntBetween(
                 "New required water?: ", 1, 4)
             animaL.ReqFoodUnit = ToolBox.InputIntBetween(
                 "New required food?: ", 1, 4)
             print("The parameters of this animal has updated")
         except AnimalNotExistException:
             ToolBox.WriteLineRed("There is no such animal...")
         time.Sleep(1500)
     elif choice == "5":  #Removing an animal
         try:
             p.arkOne.RelocateAnimal(
                 ToolBox.InputAny(
                     "What is the ID of the animal you want to relocate?: ")
             )
             ToolBox.WriteLineGreen("The animal has relocated.")
         except AnimalNotExistException:
             ToolBox.WriteLineRed("There is no such animal...")
         time.Sleep(1500)
     elif choice == "0":
         return False
     else:
         ToolBox.WriteLineRed("Wrong option!")
     return True