Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Simple Program My code posted below. Will thumbs up solution! No vectors allowed MY CODE SO FAR: #include #include using namespace std; class car

C++ Simple Program

My code posted below. Will thumbs up solution! No vectors allowed

image text in transcribed

MY CODE SO FAR:

#include

#include

using namespace std;

class car

{

private:

int quantity;

int price;

string model;

public:

car(int quantity, int price, string model);

int get_price() const;

int get_totalworth() const;

void set_price(int);

void set_quantity(int);

};

class inventory: public car

{

private:

int revenue;

int total_cars;

public:

//inventory(int revenue, int total_cars, car&);

void sell(car myCar, int quantity, int price);

int getNumberofCars() const;

int getRevenue() const;

void acceptAmount(int amount);

};

car::car(int quantity, int price, string model)

{

this->quantity = quantity;

this->price = price;

this->model = model;

}

int car::get_price() const

{

return price;

}

int car::get_totalworth() const

{

return quantity*price;

}

void car::set_price(int price)

{

this->price = price;

}

void car::set_quantity(int quantity)

{

this->quantity = quantity;

}

void inventory::sell(car myCar, int n, int price)

{

total_cars = total_cars - n;

revenue = revenue - price;

}

int inventory::getNumberofCars() const

{

return total_cars;

}

int inventory::getRevenue() const

{

return revenue;

}

void inventory::acceptAmount(int amount)

{

revenue += amount;

}

int main()

{

car honda(10, 25000, "Accord");

//inventory store(0, 0, honda);

cout

cout

cout

honda.set_price(50000);

honda.set_quantity(20);

cout

cout

cout

cout

//cout

// inventory.sell(honda, 2, 50000);

// cout

// cout

// cout

return 0;

}

A car manufacturing company is looking for a system that can handle production and selling. This system can handle multiple car productions, car sales, and revenue management. The goal is to use classes to implement data structure and operations to handle these efficiently. In order to meet this goal, you are required to have 2 different classes. One of the classes accommodate the entity of 'car' which should have the following hidden variables Quantity of the cars Price of each car Model of the cars Construct the class by adding the cars to the inventory and the revenue Assuming your class is called car, in a sample class initialization, you will add 10 Honda to your inventory with the price of 25000 dollars each, and the model of Accord (string) car honda(10, 25000, "Accord") Your car class can handle the following functions Get the price of the car Get the total worth of the cars. For instance, if you have added 5 cars with S5000 price, the function return $25000 as an integer value Set the Price of the car Set the quantity of the cars * Another requirement is to have a class to accommodate sales. This class accommodates the total number of cars in the inventory and the revenue amount of the company as hidden variables. This class provides these simple functions . Selling a car: o o Decreases inventory by the quantity of sale Decrease revenue based on the quantity and the price of sale. You have to pass car as a parameter of the function. For example, selling 2 honda with the price of $10000 has to decrease 2 from the number of cars in the inventory and $20,000 from the revenue amount. Syntax: inventory.sell(honda, 2, 2000); Get total number of cars in the inventory as of the moment. (Returns the number of cars in the inventory)- Example: inventory.getNumberofCars0; Get the revenue. (Returns the amount of revenue) - Example: inventory.getRevenue0; Accept an amount and add that into the revenue. Functions accepts an integer value and add that to the revenue amount. - Example: inventory.acceptAmount(int 120000) Construct the class by initialize a starting revenue Your program should be able to handle this sample set of operations Initialize the revenue to 0 or another amount. * Add some cars to the inventory . Get price of a car * Sell some cars by providing quantity and the price Get the revenue amount. Accept a custom amount and add it to the revenue

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_2

Step: 3

blur-text-image_3

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

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions