Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CSCI1410 – PA3 Part I (10 Points): For this part of the assignment you will be create an outline in comments/psuedocode for the programming assignment below. Place everything in a single file, but use...

1 answer below »
CSCI1410 – PA3
Part I (10 Points):
For this part of the assignment you will be create an outline in comments/psuedocode for the programming assignment below. Place everything in a single file, but use the following comments to show how you will separate the files when you submit Part II:
your name
Dealer.h
Dealer.cpp
functions.cpp
main.cpp
There will be two classes Dealer and Car as explained below. You should define the two classes in your Dealer.h section. Then you should provide pseudocode under Dealer.cpp section to describe the functions of each class. Describe in pseudocode the main menu functions under the functions.cpp section. The main.cpp section will just consist of declaring a vector of type Dealer (if you don’t know how to do this yet, just place comments in plain English). Then you will have a menu that calls the functions.
Part II: ( 40 Points)
For this programming assignment, you will be creating a program to manage cars in a dealership. This will again be a menu driven system. You will make a vector of Dealers (there can be zero to many dealers). Each dealer can have zero to many cars on the lot, represented not by a vector, but by a dynamic a
ay. The following is your menu:
1. Read Dealers and Cars from file
2. Display Dealers
3. Choose a Dealer Number, Display Cars
4. Choose a Dealer Number, Add Ca
5. Choose a Dealer Number, List Cars and Modify a Car (EXTRA CREDIT)
6. Choose a Dealer, Sort cars by VIN (EXTRA CREDIT)
7. Write Dealers and Cars to file.
8. Exit
Your program will be object oriented (using classes, not structs) with the following classes defined in Dealer.h:
Dealer.h
#ifndef _DEALER
#define _DEALER
class Dealer {
private:
string dealerName;
int dealerNumber;
int numberOfCars;
Car *carA
ayPtr;
This is the pointer to dynamic a
ay of Car, you can also declare this to

e public
public:
Dealer ( )
Dealer ( string _dealerName, int _dealerNumber);
void setDealerName (string _dealerName);
void setDealerNumber (string _dealerNumber);
void setNumberOfCars ( int _numberOfCars);
void setCarA
ay(Car * carA
ayPtr);
You don’t need this if the attribute is public
string getDealerName ( );
int getDealerNumber ( );
int getNumberOfCars( );
Car* getCarA
ay();
You don’t need this if the a
ay pointer is public
+ friend ostream & operator
(ostream &out, Dealer _dealer);

Print the Dealer Name and Number and Blank line for a specific dealer.
};
class Ca
{
private:
string vin;
string make;
string model;
int year;
double price;
public:
Car( );
Car(string _vin, string _make, string model, int year, double price);
+ getVIN( ):string
+ getMake( ):string
+ getModel( ):string
+ getYear( ):int
+ getPrice( ):double
+ setVIN(_VIN:string):void
+ setMake(_make:string):void
+ setModel(_model:string):void
+ setYear(_year:int):void
+ setPrice(_price:double):void
+ friend operator
(out: ostream &, Car: _car):ostream &

Print the VIN, Make, Model, Year, Price and Blank line for a specific car.
#endif
You will have four files for your program (Use these file names!): main.cpp, functions.h, Dealer.h, Dealer.cpp. Place into a file folder named LastnamePA3, then zip the content and hand in a zip file to canvas
· main.cpp: this will be your driver file.
· functions.h: this will contain your functions for each of the menu items.
· Dealer.h: this will contain the class declarations for Car and Dealer including the operator
.
· Dealer.cpp: this will contain the class implementations for Car and Dealer.
Remember, you do not #include “Dealer.cpp”, just #include “functions.h” and #include “Dealer.h” in main.cpp.
You will be storing your dealer objects in a vector. In the main function, you will create a vector of Dealers. When the menu is called, you will have to check your vector and ensure that it is not empty (size == 0) before refe
ing to the index number of the vector. Your Dealer vector points to a dynamic a
ay of cars (remember dynamic a
ays use the keyword new). When you access the cars class you should verify that it is not set to nullptr before accessing it.
You may not use any global variables, so must pass vectors and a
ays into parameters. If you want to change a vector you must pass by reference (&). If you have a
ays, you must pass size and the a
ay, but a
ays are already pointers, so do not use & when passing an a
ay.
Each menu item will have a co
esponding function, and the definition of the function will be found in the file functions.h. Also, your operator
function for Dealer and Car will be implemented in your functions.h. All input/output will be done in the functions and not in main (except asking for what menu option the user wants).
The following are the details for each of your menu options:
1. Read Dealers and Cars from file
2. Display Dealers
3. Choose a Dealer Number, Display Cars
4. Choose a Dealer Number, Add Ca
5. Choose a Dealer Number, List Cars and Modify a Car (EXTRA CREDIT)
6. Choose a Dealer, Sort cars by VIN (EXTRA CREDIT)
7. Write Dealers and Cars to file.
8. Exit
Option 1. Read Dealers and Cars from file
Pass the vector of dealers (from main) into the function by reference. Each Dealer will have a name and number followed by the number of cars in the dealership (on separate lines). Then you will read in a Vin, Make, Model, Year and Price for each car (on separate lines). You can assume that the number of cars as well as the Vin, Make, Model, Year and Price will be complete for each car. Each dealer can have a file format as follows:
Dealer Name
Dealer Numbe
Number of cars e.g. 2
Car1 Vin
Car1 Make
Car1 Model
Car1 Yea
Car1 Price
Car2 Vin
Car2 Make
Car2 Model
Car2 Yea
Car2 Price
Dealer Name
Dealer Numbe
Number of cars e.g. 1
Car1 Vin
Car1 Make
Car1 Model
Car1 Yea
Car1 Price
Don’t forget, between
and a getline you must use a .ignore( ) (e.g. infile.ignore( ) )
Here is an example of the input file: in.txt
John Elway Dodge
123
2
VIN123
Dodge
Ram 1500 Quad Ca
2017
XXXXXXXXXX
VIN456
Chevrolet
Traverse Premier SUV
2017
XXXXXXXXXX
Tesla Che
y Creek
234
1
VIN789
Tesla
Model X
2017
105200
Option 2. Display Dealers
Pass the vector of dealers (from main) into the function by reference. Display the Dealer Name and Number for each dealer (put a blank line between dealers). Use the
operator with cout (cout
dealer[x];)
Option 3. Choose a Dealer Number, Display Cars
Pass the vector of dealers (from main) into the function by reference. Display the Dealer Names and Numbers (menu #2). Ask the user for the dealer number, display all of the cars by using a for loop (from zero to size of the car a
ay) using the
operator with cout ( cout
dealer[x].carA
ayPtr[x];)
Option 4. Choose a Dealer Number, Add Ca
Pass the vector of dealers (from main) into the function by reference. a) Display the Dealer Names and Numbers (menu #2). b) Ask the user for the dealer number then the new car information. Follow the steps found in CSCI 1411 Lab 09 to increase the dynamic a
ay. (Essentially you will make a new a
ay, one bigger than the previous car a
ay. Then you will copy everything over from the old car a
ay to the new one. Then you will point the car pointer to the new a
ay)
You can earn up to 20% extra credit (48/40) for completing 5 and 6 as long as you get at least 80% on the required tasks.
Option 5. Choose a Dealer Number, List Cars and Modify a Car (EXTRA CREDIT)
Pass the vector of dealers (from main) into the function by reference. Display the Dealer Names and Numbers (menu #2). Ask the user for the dealer number, display cars for that dealer. Ask the user to enter the vin number for the car to modify. The user will enter new car information including car vin, make, model, year and price. Update the car information in the car a
ay of the dealer. This requires accurate access of the dealer car element.
Option 6. Choose a Dealer, Sort cars by VIN (EXTRA CREDIT)
Pass the vector of dealers (from main) into the function by reference. Display the Dealer Names and Numbers (menu #2). Ask the user for the dealer number. Sort the cars by vin and display them (with blank lines between each car)
Option 7. Write Dealers and Cars to file.
Pass the vector of dealers (from main) into the function by reference. Also pass in the filestream (from main) by reference. Call the output file out.txt. Write all of the Dealers and Cars to a separate output file in the same format as in item #1. This should include all changes to the vector and dynamic a
ay (including add, delete, modify, sorting etc.)
Option 8. Exit out of the program
What to submit:
Submit to canvas main.cpp, functions.h, Dealer.h and Dealer.cpp and the in.txt files. Each must be complete with your name on it. If you complete the extra credit, you must have 7 menu items and this must be documented in your main.cpp.
Note: You must document ALL your code and reference any code that you took from ANY source (including the internet, your book, someone else). Failure to do so may result in a grade of zero for EACH student with “too similar” code. You can work together with big ideas, but all code MUST be your own.
Page 6 of 7
Answered Same Day Dec 02, 2021

Solution

Sudipta answered on Dec 05 2021
138 Votes
HERE IS THE CODE FOR T HE REQUIRED PROBLEM AND I HAVE TESTED IT IN MY COMPUTER. IF YOU NEED SCREENSHOT OF ANSWERS THEN I WILL SEND THEM TOO.
main.cpp
Include this header file if using visual studio.
#include "stdafx.h"
Include the needed files
#include #include #include #include #include "functions.h"
using namespace std;
Define the function menu().
void menu()
{
    
Display the menu.
     cout
"Menu:"
endl;
     cout
"1. Read Dealers and Cars from file."
endl;
     cout
"2. Display Dealers."
endl;
     cout
"3. Choose a Dealer Number, Display Cars."
     endl;
     cout
"4. Choose a Dealer Number, Add Car."
endl;
     cout
"5. Choose a Dealer, Sort Cars by VIN."
     endl;
     cout
"6. Write Dealers and Cars to file."
endl;
     cout
"7. Exit."
endl;
     cout
endl;
}
Start the main() method.
int main()
{
    
Declare the required variables.
     vecto
Deale
dealerlist;
     int option;
     ofstream outFile;
     while (1)
     {
          menu();
          cout
"Enter your option:";
          cin
option;
          switch (option)
          {
              
Read dealer and car info
          case 1:
               ReadDealer(dealerlist);
              
eak;
              
Display dealer info
          case 2:
               displayDealers(dealerlist);
              
eak;
              
Display car info
          case 3:
               displayCars(dealerlist);
              
eak;
              
Add new ca
          case 4:
               addNewCar(dealerlist);
              
eak;
              
Sort the cars by VIN.
          case 5:
               sortByVIN(dealerlist);
              
eak;
              
Write the contents to a seperate file.
          case 6:
               writeToFile(dealerlist, outFile);
              
eak;
              
Exit from program.
          case 7:
               system("pause");
               return 0;
          default:
               cout
"Invalid option."
endl;
          }
     }
    
Use this command if using visual studio.
     system("pause");
     return 0;
}
Car.h
#pragma once
Include the required header files.
#ifndef _CAR_H
#define _CAR_H
#include #include using namespace std;
Define the car class.
class Ca
{
    
Declare the required private member variables.
private:
     string VIN;
     string make;
     string model;
     int year;
     double price;
    
Declare the required public methods.
public:
     Car();
     Car(string vVIN, string vMake, string vModel, int
     vYear, double vPrice);
    
Accessors
     string getVIN();
     string getMake();
     string getModel();
     int getYear();
     double getPrice();
    
mutators
     void setVIN(string _VIN);
     void setMake(string _make);
     void setModel(string _model);
     void setYear(int _year);
     void setPrice(double _price);
    
Print
     friend ostream & operato
(ostream & out, Car _car);
};
#endif
Dealer.h
#pragma once
Include the required header files.
#ifndef _DEALER_H
#define _DEALER_H
#include#include#include "Car.h"
using namespace std;
Define the class Deale
class Deale
{
    
Declare the private required variables.
private:
    
variables.
     string dealerName;
     int dealerNumber;
     Car* carA
ayPtr;
     int numberOfCars;
public:
    
Declare the public member functions.
     Dealer();
     Dealer(string dName, int dNumber);
    
mutators
     void setDealerName(string _dealerName);
     void setDealerNumber(int _dealerNumber);
     void setCarA
ayPtr(Car * _carA
ayPtr);
     void setNumberOfCars(int _numberOfCars);
    
Accessors
     string getDealerName();
     int getDealerNumber();
     int getNumberOfCars();
     Car* getCarA
ayPtr();
     friend ostream & operato
(ostream & out, Deale
     _dealer);
};
#endif
Car.cpp
Include this header file if using visual studio.
#include "stdafx.h"
#include "Car.h"
Define the required member functions of the Car class.
Car::Car()
{
     VIN = "";
     make = "";
     model = "";
     year = 0;
     price = 0;
}
Car::Car(string vVIN,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here