Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FOLLOW INSTRUCTIONS, C++ Team Project Description Your team will develop a solution for a car dealership. The program includes two classes, Dealer and Car, and

FOLLOW INSTRUCTIONS, C++
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Team Project Description Your team will develop a solution for a car dealership. The program includes two classes, Dealer and Car, and all car objects are created by the Dealer object. The fields and methods required for each class are: class Dealer private: unsigned short count // The number of cars in inventory string name Car** inventory unsigned short brandLength void setBrandlength (string) compares the length of the parameter + 2 with the current 17 value for brandlength. If the value of the parameter + 2 His greater than the current value, changes it void reduceBrandLength() 1/ checks the inventory array for the size of the largest Il brand length, and assigns it to brandLength is the value 1/ Cound is smaller unsigned short model Length void setModelLength (string) V compares the length of the parameter + 2 with the current I value for model Length 14 the value of the parameter 2 is greater than the current value, changes void reduceModellength() W check the Inventory array on the size ok the largest model length, and assigns it to mode Length in the value found 1 smaller void order Inventory () 7 Orders the cars in triventory alphabetically by brand name, then by model name, and then by number public: Dealer (initializes numerie Fields to name to the empty sering, and inventory to the null pointer Dealer (string) // initializes numeric fields to 0, name to // the parameter's value, and inventory to the null pointer void addCar (atring, string) // Receives a car's brand and model as parameters. Creates a // new Car object and adds it to Inventory, increments count, // and calls the setModelLength, setBrandLength, and // order Inventory methods void sellcar(string, string) // Receives a car's brand and model as parameters. Calls // EindCar to make sure there is a car with the same brand // and model in inventory, if not the method ends. If ound, // removes the car from inventory, decrements count, invokes // the Car object's destructor and calls the 11 reduceModellength and reduceBrandLength methods. void sellCar (string) // Receives a car's serial number as parameter. Calls // Eindcar to make sure there is a car with the same serial 1/ number in inventory, if not the method ends. If found, 1/ removes the ear from inventory, decrements count, invokes 17 the car object's destructor and calls the 1/ reduceModelLength and reduceBrandLength methods. void findCar (string, string) const // receives a car's brand and model as parameters and W searches the inventory for a car with the given brand and model names. I found, returns the index number of the first instance, otherwise, returns -1 void findCar (string) const 1 receives a car's serial number as parameter and searches Hthe inventory for the serial number. TE Eound, returns the Hindex number, otherwise, returns -1 void printBrandInventory() const H/ print the count of cars per brand. First, it prints the W/ phrase "Dealer Iname has quantity of cars in inventory. It then prints & table with the headers BRAND and COUNT, W uzing brandLength as the size of the BRAND column. If there 77 are no cars in inventory, the table (including the headers) // is not printed. void printModelInventory () const // prints the count of cars per model. First, it prints the 1/ phrase "Dealer [name] has (quantity] of cars in inventory." // It then prints a table with the headers BRAND, MODEL, and 1/ COUNT, using brandLength as the size of the BRAND column, // and model Length as the size of the MODEL column. If there // are no cars in inventory, the table (including the headers) 11 is not printed. void printDetailedInventory () const // Prints a detailed inventory. First, it prints the 1/ phrase "Dealer (name] has quantity of cars in inventory." // It then prints a table with the headers BRAND, MODEL, and // SERIAL NUMBER, using brandLength as the size of the BRAND 1/ column, and modelLength as the size of the MODEL column. // If there are no cars in inventory the table (including // the headers) is not printed. class Car private: statie unsigned short count // count is the number of car objects created string brand string model string serialNumber string assignSerial Number() assignSerialNumber 19 a private method which considers the brand, model, and count to create a 9-symbol string. 1/ The format is first three letters of the brand, first three 77 letters of the model and the 3-digit count value 1/IE Toyota Yaris is the first car added, the serial number I would be TOYYAR001 1/ If the brand and model fields have not been assigned a value, the method DOES NOT create a serial number, and // returns the empty string public: Car() // Assigns the empty string to all three fields, and // increments count by 1 Car (string, string) // The parameterized constructor increments count by 1 1/ assigns the brand and model to the fields, and calls // the assignSerialNumber method to create the serial number -Car() // The destructor prints the message 7/ The car (brand) (model) with serial number (serial number) 7 has been sold" void setBrand (string) // sets brand value IFF not set before void setModel (string) // sets model value IFF not set before string getBrand() const // If no brand, return empty string string getModel() const // If no model, return empty string string getSerialNumber() const // Returns the empty string if serial number not set void printCar (unsigned short, unsigned short) 77 printCar prints the car's details in a table-like manner 17 using the format car_brand car_model serial number 7 It uses the parameters as the size of the brand and model 17 Eields, and prints N/A is the fields have no value Once both classes have been defined implement the solution in a file named finalProject.cpp. This file, which includes main, uses a series of methods to present the human user with an interface to add cars to inventory, sell cars from inventory, and print all versions of the inventory. The menu method must show the following menu: Select one of the following: 1. Add a car to inventory 2. Sella cer from Inventory 3. Find a car by brand and mode 1 4. Print the brand inventory 5. Print the model inventory 6. Print the detailed inventory 7. Exit the application Your selection: The method returns an integer value which should be used by the execute method to implement the selected option. The execute method receives and integer as parameter and performs the requested action by calling upon methods of the Dealer object. If the value of the parameter is incorrect the execute method prints an error message. The execute method returns true unless the selected option is number 7. The structure of main is: int main() { Dealer poli ("Poli Auto Sales"); while (execute (menu ()); system ("pause"); // Visual Studio only! return 0; You should add at least 10 cars to inventory and make sure that all methods work properly. Your team will present the program to the class on the scheduled date and time

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