Question: Task 2 : Class Tree Consider the following two class definitions in the textbook: class Position { public: int& operator * ( ) ; Position
Task : 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: Implement class Tree assuming the linked structure for a general tree shown in Figure 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. 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
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
