ntory program   COMMAND MENU add- add items to wizard_all_items.txt walk - Walk down the p

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Wizard Program C++

 

Console 

The Wizard Inventory program

 

COMMAND MENU

add- add items to wizard_all_items.txt

walk - Walk down the path

show - Show all items from text file wizard_all_items.txt

search - search for items from wizard_all_items.txt

drop - Drop an item

exit - Exit program

 

command: add

Walking down a path, you see a rock.

Do you want to add it to inventory? y/n:y

Rock is now added to inventory

 

Command: search

You are searching your bag for a water bottle.

If found return you pull your water bottle out, if not found say "water bottle is not in inventory, keep walking down path to add it to your inventory"

 

Command: walk

While walking down a path, you see a crossbow.

Do you want to grab it? (y/n): y

You picked up a crossbow.

 

Command: show

1. a crossbow

 

Command: drop

Number: -1

Invalid item number.

 

 

Command:

The error message if the program can’t find the items file

Could not find file: wizard_all_items.txt

Exiting program.  Bye!

Specifications

  • The file named wizard_all_items.txt is attached and contains a list of all possible items that a wizard can carry. When the user selects the walk command, read these items from the file, randomly pick one, and give the user the option to grab it.
  • User should be able to add items to wizard_all_items to have in inventory
  • User should be able to search text file wizard_all_items for items
  • The current items that the wizard is carrying should be stored in wizard_inventory.txt. Make sure it updates this file every time the user grabs or drops an item.
  • The program should use a function to read the list of items and the wizard’s inventory from a file. If this function can’t find the file, it should throw an exception. Then, the calling code should catch and handle this exception in an appropriate way. 
  • If the items file is missing, display an appropriate error message and exit the program. Comments are provided on lines 46,48,51 and 53 to indicate where the exceptions should be handled.
  • If the inventory file is missing, display an appropriate error message and continue with an empty inventory for the user. That way, the program will create a new inventory file when the user adds items to the inventory.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Running Time of Application
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education