daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Jan 13th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Programmer: Kyle
  2. // Project: Car AutoDealership
  3. // Date: 10/8/11
  4.  
  5. #include "stdafx.h"
  6. #include <iostream>
  7. #include <string>
  8. #include <cstdlib>
  9. #include <cctype>
  10. #include <vector>
  11.  
  12. using namespace std;
  13.  
  14. class AutoDealership
  15. {
  16.  
  17. private:
  18.  
  19.     int dlr_inv_num;
  20.     string vin;
  21.     string make;
  22.     string model;
  23.     string ext_color;
  24.     string int_color;
  25.     string transmission_type;
  26.     int engine_size;
  27.     double wholesalePrice;
  28.     double retailPrice;
  29.  
  30.     void checkInput();
  31.  
  32. public:
  33.  
  34.     AutoDealership();
  35.     AutoDealership(int newDlr_inv_num, string newAutoVIN, string newMake, string newModel,
  36.         string newExt_color, string newInt_color, string newTransmission_type, int newEngine_size,
  37.         double newWholeSalePrice, double newRetailPrice);
  38.  
  39.     friend bool operator==(int &dlrInvNumberToCheck, const AutoDealership &num1);
  40.  
  41.     int get_dlr_inv_num();
  42.     string get_make();
  43.     string get_model();
  44.     void add_auto();
  45.     void delete_auto();
  46.     void display_auto();
  47.  
  48. };
  49.  
  50. void displayTotalCars(int);
  51.  
  52.  
  53. int main()
  54. {
  55.  
  56.  
  57.     int dlr_inv_num = 1000, engine_size=0, choiceEntered, dlrInvNumberToCheck;
  58.     double wholesalePrice=0.00, retailPrice=0.00;
  59.     string vin="", make="", model="", ext_color="", int_color="", transmission_type="";
  60.     bool spaceLeft = true;
  61.     vector<AutoDealership> cars;
  62.  
  63.     cout << "Welcome to the AutoDealership program." << endl << endl;
  64.  
  65.     do {
  66.  
  67.         cout << "1.) Add a car" << endl
  68.              << "2.) Delete a Car" << endl
  69.              << "3.) Search car by dealer inventory number, make or model" << endl
  70.              << "4.) Display total cars in inventory" << endl
  71.              << "5.) Exit Program" << endl << endl
  72.              << "Make selection: ";
  73.         cin  >> choiceEntered;
  74.         cout << endl;
  75.        
  76.         if (choiceEntered == 1 && spaceLeft)
  77.         {
  78.  
  79.             AutoDealership v(dlr_inv_num, vin, make, model,
  80.                 ext_color, int_color, transmission_type, engine_size,
  81.                 wholesalePrice, retailPrice);
  82.             v.add_auto();
  83.             cars.push_back(v);
  84.  
  85.             dlr_inv_num++;
  86.             // check to see if car lot is full
  87.             if (dlr_inv_num == 1100)
  88.             {
  89.                 cout << "Car lot is full. In order to add an additional car now, you must delete another." << endl;
  90.                 spaceLeft = false;
  91.             }
  92.  
  93.         }
  94.  
  95.         else if (choiceEntered == 2)
  96.  
  97.             cout << "DELETE CAR" << endl << endl;
  98.  
  99.         else if (choiceEntered == 3)
  100.         {
  101.             cout << "Enter Dealer Inventory Number to check (1000-1100): ";
  102.             cin >> dlrInvNumberToCheck;
  103.  
  104.             for (int i=0; i < cars.size(); i++)
  105.             {
  106.                 if (dlrInvNumberToCheck == cars[i])
  107.                 {
  108.                     cout << "A match has been found. The attributes are: " << endl;
  109.                         cars[i].display_auto();
  110.                 } else
  111.                     cout << "No match has been found." << endl << endl;
  112.  
  113.             }
  114.  
  115.         }
  116.  
  117.         else if (choiceEntered == 4)
  118.             displayTotalCars(dlr_inv_num);
  119.            
  120.  
  121.     } while (choiceEntered != 5);
  122.    
  123.    
  124.  
  125.     return 0;
  126.  
  127. }
  128.  
  129. //Constructor
  130. AutoDealership::AutoDealership()
  131. {
  132.  
  133.  
  134. }
  135.  
  136. AutoDealership::AutoDealership(int newDlr_inv_num, string newAutoVIN, string newMake, string newModel,
  137.         string newExt_color, string newInt_color, string newTransmission_type, int newEngine_size,
  138.         double newWholeSalePrice, double newRetailPrice)
  139.     : dlr_inv_num(newDlr_inv_num), vin(newAutoVIN), make(newMake), model(newModel),
  140.         ext_color(newExt_color), int_color(newInt_color), transmission_type(newTransmission_type), engine_size(newEngine_size),
  141.         wholesalePrice(newWholeSalePrice), retailPrice(newRetailPrice)
  142. {
  143.    
  144. }
  145.  
  146. bool operator==(int &dlrInvNumberToCheck, const AutoDealership &num1)
  147. {
  148.     return (dlrInvNumberToCheck == num1.dlr_inv_num);
  149. }
  150.  
  151. // Add a Car
  152. void AutoDealership::add_auto()
  153. {
  154.  
  155.     cout << "Enter vin: ";
  156.     cin >> vin;
  157.     cout << "Enter make: ";
  158.     cin >> make;
  159.     cout << "Enter model: ";
  160.     cin >> model;
  161.     cout << "Enter Exterior Color: ";
  162.     cin >> ext_color;
  163.     cout << "Enter Interior Color: ";
  164.     cin >> int_color;
  165.     cout << "Enter Transmission Type: ";
  166.     cin >> transmission_type;
  167.     cout << "Enter Engine Size (Cubic Inches): ";
  168.     cin >> engine_size,
  169.     cout << "Enter Wholesale Price: ";
  170.     cin >> wholesalePrice;
  171.     cout << "Enter Retail Price: ";
  172.     cin >> retailPrice;
  173.     cout << endl;
  174.  
  175. }
  176.  
  177. // Delete a Car
  178. void AutoDealership::delete_auto()
  179. {
  180.  
  181.  
  182. }
  183.  
  184. void AutoDealership::display_auto()
  185. {
  186.  
  187.     cout << "Car vin:" << vin << ", "
  188.          << "Car make: " << make << ", "
  189.          << "Car model: " << model << ", "
  190.          << "Car Exterior Color: " << ext_color << ", "
  191.          << "Car Interior Color: " << int_color << ", "
  192.          << "Car Transmission Type: " << transmission_type << ", "
  193.          << "Car Engine Size (Cubic Inches): " << engine_size << ", "
  194.          << "Car Wholesale Price: " << wholesalePrice << ", "
  195.          << "Car Retail Price: " << retailPrice << ", "
  196.          << endl << endl;
  197.  
  198. }
  199.  
  200. // Check to make sure they entered correct wholesale and retail prices
  201. void AutoDealership::checkInput()
  202. {
  203.  
  204.  
  205. }
  206.  
  207. void displayTotalCars(int dlr_inv_num)
  208. {
  209.     int totalCarsAdded;
  210.  
  211.     totalCarsAdded = dlr_inv_num-1000;
  212.  
  213.     cout << "Total Number of Cars Added: " << totalCarsAdded << endl << endl;
  214. }
  215.  
  216. int AutoDealership::get_dlr_inv_num()
  217. {
  218.     return dlr_inv_num;
  219. }
  220.  
  221. string AutoDealership::get_make()
  222. {
  223.     return make;
  224. }
  225.  
  226. string AutoDealership::get_model()
  227. {
  228.     return model;
  229. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top