So We have started our monster system together, and our goal is when we run our code, it will look like the example below. To do that we need to do a few things
Please select one of the following
1. Add Monster
2. List all monsters
3. Play Adventure
Enter your selection (Enter ‘exit’ to quit): 1
ADD MONSTER
Enter monster species: Spider
Enter monster health: 10
Enter monster max_attack: 20
You have added Spider into our system.
Please select one of the following
1. Add Monster
2. List all monsters
3. Play Adventure
Enter your selection (Enter ‘exit’ to quit): 2
– Dragon – 100 health – 50 Max attack
– Troll – 50 health – 20 Max attack
– Water Golem – 30 health – 20 Max attack
– Cyclops – 60 health – 30 Max attack
– Spider – 10 health – 20 Max attack
Examples that might help you
Fruit Store
# Part 1 Finish the Fruit class # just self. __________________ # name and color is Strings # is_it_sweet is True or False # barcord_numberis number class Fruit: def __init__(self,name,color,is_it_sweet,barcode_number): self.name = name self.color = color self.is_it_sweet = is_it_sweet self.barcode_number = barcode_number class Fruit_store: # Part 2 I need you to create 2 empty dictionaries # fruit_by_name {name:fruit} # fruit_by_barcode {barcode:fruit} def __init__ (self): self.fruit_by_name = {} self.fruit_by_barcode = {} # part 3 # i want you to write the code that lets someone add a fruit to the store def add_fruit(self): name = input("What is the fruit's name?") color = input("what is the fruit's color?") is_it_sweet = input("is the fruit sweet?") barcode_number = input("what is the barcode number of your fruit?") fruit = Fruit(name,color,is_it_sweet,barcode_number) self.fruit_by_name[name] = fruit self.fruit_by_barcode[barcode_number] = fruit print("You have added your fruit") # part 4 # pick a dictionary, and use it to list all the fruit and its information def list_fruit(self): for f in self.fruit_by_name.values(): print(f"the fruit's name is{f.name}and the fruit's {f.color} {f.is_it_sweet} {f.barcode_number}") # part 5 # same as list_fruit, but you must check if the fruit is sweet before printing def find_all_sweet_fruit(self): for f in self.fruit_by_name.values(): if f.is_it_sweet.lower() == "true": print(f"the fruit's name is {f.name} and the fruit's {f.color} {f.is_it_sweet} {f.barcode_number}") #part 6 # the user will ask for a fruit with input, and you need to print the info def find_fruit_by_name(self): question_of_fruit = input("what fruit are you looking for?") if question_of_fruit in self.fruit_by_name.keys(): found_fruit = self.fruit_by_name[question_of_fruit] print(f"the fruit's name is {found_fruit.name} and the fruit's {found_fruit.color} {found_fruit.is_it_sweet} {found_fruit.barcode_number}") else: print("We don't have your fruit") def application_loop(self): menu = """ 1. Add A Fruit 2. List all fruits 3. find all sweet fruits 4. find fruits by name 5. End Application Enter Your selection here:""" while True: response = input(menu) if response=="1": self.add_fruit() elif response=="2": self.list_fruit() elif response == "4": self.find_fruit_by_name() elif response == "3": self.find_all_sweet_fruit() elif response == "5": break else: print("Bad answer") ranch_nine_nine= Fruit_store() #ranch_nine_nine.add_fruit() #<--- we do the code to add the fruit ranch_nine_nine.application_loop()