Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Programmer: Kyle
- // Project: Car AutoDealership
- // Date: 10/8/11
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <cctype>
- #include <vector>
- using namespace std;
- class AutoDealership
- {
- private:
- int dlr_inv_num;
- string vin;
- string make;
- string model;
- string ext_color;
- string int_color;
- string transmission_type;
- int engine_size;
- double wholesalePrice;
- double retailPrice;
- void checkInput();
- public:
- AutoDealership();
- AutoDealership(int newDlr_inv_num, string newAutoVIN, string newMake, string newModel,
- string newExt_color, string newInt_color, string newTransmission_type, int newEngine_size,
- double newWholeSalePrice, double newRetailPrice);
- friend bool operator==(int &dlrInvNumberToCheck, const AutoDealership &num1);
- int get_dlr_inv_num();
- string get_make();
- string get_model();
- void add_auto();
- void delete_auto();
- void display_auto();
- };
- void displayTotalCars(int);
- int main()
- {
- int dlr_inv_num = 1000, engine_size=0, choiceEntered, dlrInvNumberToCheck;
- double wholesalePrice=0.00, retailPrice=0.00;
- string vin="", make="", model="", ext_color="", int_color="", transmission_type="";
- bool spaceLeft = true;
- vector<AutoDealership> cars;
- cout << "Welcome to the AutoDealership program." << endl << endl;
- do {
- cout << "1.) Add a car" << endl
- << "2.) Delete a Car" << endl
- << "3.) Search car by dealer inventory number, make or model" << endl
- << "4.) Display total cars in inventory" << endl
- << "5.) Exit Program" << endl << endl
- << "Make selection: ";
- cin >> choiceEntered;
- cout << endl;
- if (choiceEntered == 1 && spaceLeft)
- {
- AutoDealership v(dlr_inv_num, vin, make, model,
- ext_color, int_color, transmission_type, engine_size,
- wholesalePrice, retailPrice);
- v.add_auto();
- cars.push_back(v);
- dlr_inv_num++;
- // check to see if car lot is full
- if (dlr_inv_num == 1100)
- {
- cout << "Car lot is full. In order to add an additional car now, you must delete another." << endl;
- spaceLeft = false;
- }
- }
- else if (choiceEntered == 2)
- cout << "DELETE CAR" << endl << endl;
- else if (choiceEntered == 3)
- {
- cout << "Enter Dealer Inventory Number to check (1000-1100): ";
- cin >> dlrInvNumberToCheck;
- for (int i=0; i < cars.size(); i++)
- {
- if (dlrInvNumberToCheck == cars[i])
- {
- cout << "A match has been found. The attributes are: " << endl;
- cars[i].display_auto();
- } else
- cout << "No match has been found." << endl << endl;
- }
- }
- else if (choiceEntered == 4)
- displayTotalCars(dlr_inv_num);
- } while (choiceEntered != 5);
- return 0;
- }
- //Constructor
- AutoDealership::AutoDealership()
- {
- }
- AutoDealership::AutoDealership(int newDlr_inv_num, string newAutoVIN, string newMake, string newModel,
- string newExt_color, string newInt_color, string newTransmission_type, int newEngine_size,
- double newWholeSalePrice, double newRetailPrice)
- : dlr_inv_num(newDlr_inv_num), vin(newAutoVIN), make(newMake), model(newModel),
- ext_color(newExt_color), int_color(newInt_color), transmission_type(newTransmission_type), engine_size(newEngine_size),
- wholesalePrice(newWholeSalePrice), retailPrice(newRetailPrice)
- {
- }
- bool operator==(int &dlrInvNumberToCheck, const AutoDealership &num1)
- {
- return (dlrInvNumberToCheck == num1.dlr_inv_num);
- }
- // Add a Car
- void AutoDealership::add_auto()
- {
- cout << "Enter vin: ";
- cin >> vin;
- cout << "Enter make: ";
- cin >> make;
- cout << "Enter model: ";
- cin >> model;
- cout << "Enter Exterior Color: ";
- cin >> ext_color;
- cout << "Enter Interior Color: ";
- cin >> int_color;
- cout << "Enter Transmission Type: ";
- cin >> transmission_type;
- cout << "Enter Engine Size (Cubic Inches): ";
- cin >> engine_size,
- cout << "Enter Wholesale Price: ";
- cin >> wholesalePrice;
- cout << "Enter Retail Price: ";
- cin >> retailPrice;
- cout << endl;
- }
- // Delete a Car
- void AutoDealership::delete_auto()
- {
- }
- void AutoDealership::display_auto()
- {
- cout << "Car vin:" << vin << ", "
- << "Car make: " << make << ", "
- << "Car model: " << model << ", "
- << "Car Exterior Color: " << ext_color << ", "
- << "Car Interior Color: " << int_color << ", "
- << "Car Transmission Type: " << transmission_type << ", "
- << "Car Engine Size (Cubic Inches): " << engine_size << ", "
- << "Car Wholesale Price: " << wholesalePrice << ", "
- << "Car Retail Price: " << retailPrice << ", "
- << endl << endl;
- }
- // Check to make sure they entered correct wholesale and retail prices
- void AutoDealership::checkInput()
- {
- }
- void displayTotalCars(int dlr_inv_num)
- {
- int totalCarsAdded;
- totalCarsAdded = dlr_inv_num-1000;
- cout << "Total Number of Cars Added: " << totalCarsAdded << endl << endl;
- }
- int AutoDealership::get_dlr_inv_num()
- {
- return dlr_inv_num;
- }
- string AutoDealership::get_make()
- {
- return make;
- }
- string AutoDealership::get_model()
- {
- return model;
- }
Add Comment
Please, Sign In to add comment