Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Carprocon.which helps you decide between two cars The class should have a class - wide ( member attribute ) variable called

Create a class called Carprocon.which helps you decide between two cars
The class should have a class-wide (member attribute) variable called budget and set it to 50,000
The class should have the following instance variables:
price (a double)
model (a string containing make and model)
pros (a vector of strings)
cons (a vector of strings)
propoints (a vector of integers)
conpoints (a vector of integers)
The class should have the following methods
0. A constructor which takes the budget as argument, [For C++ only, make a second overloaded constructor that can also take the make and model (a string) and the price (double) and use the second constructor for the second instance so you dont have to call setcar for the second instance.]
setcar takes as input the make and model (a string) and the price (double)
setpro takes as input a pro for example Great gas mileage as well as an integer which (1-10) ie: 10 being high priority. It adds the pro to the pros list and adds the points to the propoints
setcon takes as input a pro for example No warranty as well as an integer which (1-10) ie: 10 being high priority. It adds the con to the cons list and adds the points to the conpoints
A printit method that prints out the budget, price, model, pros, cons, propoints, conpoints out nicely.
A sum method that takes as argument an arraylist/or Python list of integers and returns the sum of them
A Compare method takes as input another car instance c and compares it to the data in this instance and decides what car you should buy. It does this by:
ctotal = c_propoints - c_conpoints and thistotal = this_propoints - this_conpoints
Is the best formula, This way the cons are deducted and whichever car is left with the higher amount of pros would win
, Let the user know the totals, and the largest takes priority for c (lets call it ctotal). Add up the pro points of this, and add up the con points of this. Let the user know the totals, the largest takes priority for this (lets call it thistotal). Use your sum function to add up.
The larger of total and thistotal becomes the winner and the car you they should be. Make sure to print out total, thistotal, ie:explain your final conclusion of what car make/model they should buy.
30 points
In your main create two car instances, for example car1, and car2. Populate the data in each (in the interest of time you do not have to make a user interface. You can hard code the data into your method calls in main. For each instance you will call setcar, and setpro (add five pros with priority) and setcons (add five cons with priority).
Call the printit method for the first car1
Call the printit method for the second car2
Now Call the compare method of the car2 and send in as an argument the first cars instance handle. The car2s compare method will compare car1 with its own data and decide which car is better for you to buy.

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

More Books

Students also viewed these Databases questions