Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I need to know how to achieve the following in C++ : 1).Implement the class Car and class Collection. 2). Include required libraries as

Hi,

I need to know how to achieve the following in C++ :

1).Implement the class Car and class Collection. 2). Include required libraries as necessary; 3). Add namespaces as necessary; 4). Overload the comparison operator < which is used by the priority_queue to determine the top of the queue. 5). void Collection::display_best() should use the void Car::display to display the Car specific information.

Test run the program and make sure that you get the output as: Sample output: C:\csc2401>g++ -Wall PartB-1.cpp C:\csc2401>a Sports Car From 1900 to 2014 Model: AH211 Price: 23456.8

Using the following code :

class Car { public: Car(); Car(string m, double p); string get_model(); double get_price(); void display()const; private: string model; double price; };

class Collection { public: Collection(); Collection(string n, string d); void add_item(Car c); // Add Car c to priority_queue task. void display_best(); // Display information of the Best car. // Use price to determine best. // Higher price means better. private: priority_queue task; string name; // Name of the collection string description; // Descriptions of the collection };

int main(){ // Instantiate 3 car objects Car c1("MQ310", 12345.99); Car c2("AH211", 23456.78); Car c3("ZH42", 3456.49); // Instantiate a Collection object Collection c("Sports Car", "From 1900 to 2014"); // Add 3 car objects to the car collection c.add_item(c1); c.add_item(c2); c.add_item(c3); // Display the information of the best car. c.display_best(); return 0; }

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Discuss the Rights issue procedure in detail.

Answered: 1 week ago

Question

Explain the procedure for valuation of shares.

Answered: 1 week ago