Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 2 : Class Tree Consider the following two class definitions in the textbook: class Position { public: int& operator * ( ) ; Position

Task 2: Class Tree Consider the following two class definitions in the textbook: class Position { public: int& operator*(); Position parent() const; PositionList children() const; bool isRoot () const; bool isExternal () const; } class Tree { public: class Position { public: int& operator*(); Position parent() const; PositionList children() const; bool isRoot () const; bool isExternal () const; } std::list PositionList; public: Tree(); int size() const; bool empty() const; Position root () const; PositionList positions() const; void add (const Tree& T, const string& mn, float p, float m, const string& t); void preOrderPrint (const Tree& T, const Position& p); void postOrderPrint (const Tree& T, const Position& p); } Solve the following exercise: 1. Implement class Tree assuming the linked structure for a general tree shown in Figure 7.5 in the textbook. Each node stores the same information as class Vehicle of the previous exercise as well as one additional field called type (string) indicating if a vehicle is a Sedan, Truck, or Electric. 2. The main program should interactively ask for a character, and then execute the following actions depending on the received input character: a. A adds a new vehicle to the tree after reading the following information for the vehicle: manufacturer, price, milage, and type. b. L lists in preorder all vehicles with a price less than value V. Value V is read from the input. c. M - lists in postorder all vehicles newer than the manufacturing year Y. Value Y is read from the input. d. I lists the number of vehicles in the inventory. Implement all the methods that are needed to realize the four actions above.

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Be familiar with the different perspectives of service quality.

Answered: 1 week ago

Question

Describe key customer feedback collection tools.

Answered: 1 week ago

Question

Know what customers expect from the firm when they complain.

Answered: 1 week ago