Question: Write a program that keeps track of the items that a wizard can carry. Use a list to store the items and provide at least

Write a program that keeps track of the items that a wizard can carry. Use a list to
store the items and provide at least two starting items. The program should display the following
menu:
COMMAND MENU
show - Show all items
add - Add an item
drop - Drop an item
edit - Edit an item
exit - Exit program
Command:
If the user enters show, the program should display all the items in the list. If the user enters add,
the program should ask for the name of the item then adds it to the list. If the user enters drop,
the program should ask for the items number and then delete the item from the list. If the user
enters edit, the program should ask for the items number and the value to replace it with. Then,
it should replace the old item with the new item. Repeat the program until the user chooses the
exit command.
Your program should have at least 6 functions: the main function, a function to display the menu,
a function to display all the items in the list, a function to add an item to the list, a function to
delete an item from the list, and a function to edit the list.
Input Validation: If the user selects a command not on the menu, display an error message and
let the user enter another command. For the drop and edit commands, display an error message if
the user enters an invalid number for the item. The wizard can only carry four items at a time. Do
not use global variables.
Sample run:
The Wizard Inventory program
COMMAND MENU
show - Show all items
add - Add an item
drop - Drop an item
edit - Edit an item
exit - Exit program
Command: show
1. wooden staff
2. wizard hat
3. cloth shoes
Command: add
Name: potion of invisibility
potion of invisibility was added.
Command: show
1. wooden staff
2. wizard hat
3. cloth shoes
4. potion of invisibility
Command: add
The wizard can't carry any more items. Drop something first.
Command: edit
Number: 2
Updated name: magic hat
Item number 2 was updated.
Command: show
1. wooden staff
2. magic hat
3. cloth shoes
4. potion of invisibility
Command: drop
Number: 3
cloth shoes was dropped.
Command: 4
Not a valid command. Please try again.
Command: edit
Number: 5
Invalid item number.
Command: exit
Bye!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!