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 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
wooden staff
wizard hat
cloth shoes
Command: add
Name: potion of invisibility
potion of invisibility was added.
Command: show
wooden staff
wizard hat
cloth shoes
potion of invisibility
Command: add
The wizard can't carry any more items. Drop something first.
Command: edit
Number:
Updated name: magic hat
Item number was updated.
Command: show
wooden staff
magic hat
cloth shoes
potion of invisibility
Command: drop
Number:
cloth shoes was dropped.
Command:
Not a valid command. Please try again.
Command: edit
Number:
Invalid item number.
Command: exit
Bye!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
