Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using c++ make the code for the following problem Electrical and Computer Engineering & Computer Science Department Computer Programming II Lab Team Project Description Your

using c++ make the code for the following problem

Electrical and Computer Engineering & Computer Science Department Computer Programming II Lab

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 // value for brandLength. If the value of the parameter + 2 // is greater than the current value, changes it void reduceBrandLength() // checks the inventory array for the size of the largest // brand length, and assigns it to brandLength if the value // found is smaller unsigned short modelLength void setModelLength(string) // compares the length of the parameter + 2 with the current // value for modelLength. If the value of the parameter + 2 // is greater than the current value, changes it void reduceModelLength() // checks the inventory array for the size of the largest // model length, and assigns it to modelLength if the value // found is smaller void orderInventory() // Orders the cars in inventory alphabetically, first by brand // name, then by model name, and then by serial number. public: Dealer() // initializes numeric fields to 0, name to the // empty string, 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(string, 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 // orderInventory methods void sellCar(string, string) // Receives a car's brand and model as parameters. Calls // findCar to make sure there is a car with the same brand // and model in inventory, if not the method ends. If found, // removes the car from inventory, decrements count, invokes // the Car object's destructor and calls the // reduceModelLength and reduceBrandLength methods. void sellCar(string) // Receives a car's serial number as parameter. Calls // findCar to make sure there is a car with the same serial // number in inventory, if not the method ends. If found, // removes the car from inventory, decrements count, invokes // the Car object's destructor and calls the // reduceModelLength and reduceBrandLength methods. void findCar(string, string) const // receives a car's brand and model as parameters and // searches the inventory for a car with the given brand and // model names. If found, returns the index number of the // first instance, otherwise, returns -1 void findCar(string) const // receives a car's serial number as parameter and searches // the inventory for the serial number. If found, returns the // index number, otherwise, returns -1 void printBrandInventory() const // prints the count of cars per brand. First, it prints the // phrase Dealer [name] has [quantity] of cars in inventory. // It then prints a table with the headers BRAND and COUNT, // using brandLength as the size of the BRAND column. If there

// 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 // phrase Dealer [name] has [quantity] of cars in inventory. // It then prints a table with the headers BRAND, MODEL, and // COUNT, using brandLength as the size of the BRAND 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. void printDetailedInventory() const // Prints a detailed inventory. First, it prints the // 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 // 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: static unsigned short count // count is the number of Car objects created string brand string model string serialNumber string assignSerialNumber() // assignSerialNumber is a private method which considers // the brand, model, and count to create a 9-symbol string. // The format is first three letters of the brand, first three // letters of the model and the 3-digit count value // If a Toyota Yaris is the first car added, the serial number // would be TOYYAR001 // If the brand and model fields have not been assigned a // value, the method DOES NOT create a serial number, and

Electrical and Computer Engineering & Computer Science Department CECS 2223 Computer Programming II Lab

// 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 // assigns the brand and model to the fields, and calls // the assignSerialNumber method to create the serial number -Car() // The destructor prints the message // The car [brand] [model] with serial number [serial number] // 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) // printCar prints the car's details in a table-like manner // using the format car brand car model serial number // It uses the parameters as the size of the brand and model // fields, and prints N/A if 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. Sell a car from inventory 3. Find a car by brand and model 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

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

3. You can gain power by making others feel important.

Answered: 1 week ago