Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ You will create a binary search tree for a product catalogue. The catalogue will be used to display products. The programs user will add

C++

You will create a binary search tree for a product catalogue. The catalogue will be used to display products. The programs user will add and delete products as well as be able to create an order of products. A product class will consist of a name, its price, and the number of items that the user is buying (all initial buying quantities are 0). Your products should be related so that program is selling related products.

Your binary search tree class will be a collection class (like the list class in the previous project with .h and .cpp files). Your tree class will make use of node pointers/objects defined in a node class. The node class will consist of the product data and node pointers left and right. The tree class will have a root data attribute that will also be a node pointer.

When the program starts, the program should read from a textfile at least 16 products with their names, prices, and quantities being purchased (quantities initially should equal 0). As the data is read, it should be added into the binary search tree. Arrange the data so that the tree will be reasonably balanced. Use the name of the product as the sorting key for the binary search tree.

After the data has been loaded from the text file, a menu should appear that prompts the user to (1) add a product, (2) edit a product, (3) find and display a product, (4) view all products, (5) delete a product, (6) find and purchase a product, (7) display the current order, (8) clear the current order, or (9) quit the program.

When the program quits, the products in the current program, including those just added and having removed all those removed, are saved to the text file so that the updated collection of products will be loaded when the program runs the next time. The quantities should all be set to 0 when saving the text file.

Additional requirements (to practice traversals): Your tree of products should have a destructor that uses a post-order traversal strategy. The view all products menu option should use an in-order traversal strategy. When displaying the current order, use a pre-order traversal strategy. When clearing the current order use a level traversal strategy.

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions