Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++. Part A Your program first ask which file to read. This will contain three commands: Item: -- This command is used to add

In C++.

Part A

Your program first ask which file to read. This will contain three commands:

Item: -- This command is used to add a new item to a list. It will provide both the item name and the price of this item.

Recipe: -- This command defines and item that is built from other basic items. The price of this item will be the sum of the individual components to make the item. It will be a list of names of other items (already defined) that it is made from.

Change: -- This will change price of an already defined item using the Item: command. It will not be used to redefine recipes. This will provide both the name of the item being redefined and the new price.

After all the items have been entered. For each Item and Recipe show the price to get this item. For part A, you can assume recipes will only be used from simple Items instead of more complex Recipes. The price changes from the Change command should be reflected on both the simple Item and in the Recipes that use the item. In other words, the change in the price should effect all products.

You may assume:

Item names will be single words.

One command per line.

Commands will be formatted as in the file (space after the command and no trailing space).

Recipes will only use Items that have already been defined.

Change will only modify Items that have already been defined.

Recipes will not be more than 50 items.

There will not be more than 500 commands in the file.

Products (both Items and Recipes) are unique. In other words, there will never be two products with the same name.

Hint: It might be useful to think about how you want to store data and handle changes efficiently before starting this part. In the next part you will have to handle greater changes, which can be done easily if you use the correct approach.

Example 1 (user input underlined):

What file to open? list.txt wood : 2.5 nail : 1.5 
tape : 2 nailbat : 7 shuriken : 8 walkingstick : 7 spear : 7.5 

Example 2 (user input underlined):

What file to open? listA.txt wood : 2.5 nail : 1.5 
tape : 4 nailbat : 7 shuriken : 10 walkingstick : 9 spear : 9.5 

Part B

This part extends your answer to part A. In addition to the three commands outlined above, you also need to incorporate one new command and modify one:

Recipe: -- This command is still used to specify a list of items from which you can build it, except it can now over other recipes as part of them.

Modify: -- This command changes the recipe list for an already defined item. This is very similar to the Change command, except for recipes.

Again, the output should simply be the list of items and their prices.

Example 1 (user input underlined):

What file to open? listB.txt wood : 1 nail : 1.5 
tape : 4 nailbat : 4 shuriken : 10 
walkingstick : 3.5 spear : 8 stilts : 15 elevatedhouse : 67 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

What do you think it means to be healthy?

Answered: 1 week ago