Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class Position { public: int& operator * ( ) ; Position parent ( ) const; PositionList children ( ) const; bool isRoot ( ) const;
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. Page 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started