Question: class InventoryManager: def _ _ init _ _ ( self ) : self.inventory = Inventory ( ) def run ( self ) : while True:
class InventoryManager:
def initself:
self.inventory Inventory
def runself:
while True:
print
Available commands:"
print Add Item"
print Remove Item"
print View Inventory"
print Exit"
command inputEnter command:
if command :
name inputEnter item name:
quantity validatedintegerinputEnter quantity:
self.inventory.additemItemname quantity
elif command :
name inputEnter item name:
quantity validatedintegerinputEnter quantity:
self.inventory.removeitemname quantity
elif command :
self.inventory.viewinventory
elif command :
break
def validatedintegerinputprompt:
while True:
try:
return intinputprompt
except ValueError:
printInvalid input, please enter an integer.
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
