Objectives

  • Design an abstract data type.
  • Learn how to use object-oriented and top-down design techniques.
  • Implement an abstract data type using a C++ class.
  • Incorporate user-friendly input/output.
  • Demonstrate input editing and error-checking criteria.
  • Demonstrate quality, efficiency and accuracy of program coding.

Description

For project 1 you will need to create a vehicle class that will store information about a single vehicle. Vehicles are identified by a model (maximum 20 characters), price (non-negative double), and the manufacturer's name and location. Manufacturer's name and location should not exceed 15 characters each.

Your program should create a menu interface that has the following options:

  • Enter the information for a vehicle.
  • Display the information for the vehicle.
  • Exit the program.

Permit the user to enter multiple vehicles, though the program will only maintain and display information about the most recently entered vehicle.

Note: Though a string class exists, for this project I want you to represent all strings as char arrays.

The vehicle class should look like:

const int MAX_MODEL = 20; const int MAX_NAME = 15; const int MAX_LOCATION = 15; class Vehicle { public: Vehicle(char mdl[] = "", double pr = 0, char nm[] = "", char loc[] = ""); // Pre-condition: mdl cannot be longer than 20 characters, // nm and loc cannot be longer than 15 characters, // pr must be non-negative // Post-condition: If mdl, nm, or loc exceed length, they will be truncated. // mdl, nm and loc will be stored in model, name and location, // respectively. If pr is // negative, 0 will be stored in price; otherwise pr will be stored in price void setVehicle(char mdl[] = "", double pr = 0, char nm[] = "", char loc[] = ""); // Pre-condition: mdl cannot be longer than 20 characters, // nm and loc cannot be longer than 15 characters, // pr must be non-negative // Post-condition: If mdl, nm, or loc exceed length, they will be truncated. // mdl, nm and loc will be stored in model, name and location, // respectively. If pr is // negative, 0 will be stored in price; otherwise pr will be stored in price void display() const; // Pre-condition: None // Post-condition: model, price, name and location will be displayed on a single line // Other functions as needed private: char model[MAX_MODEL + 1]; double price; char name[MAX_NAME + 1]; char location[MAX_LOCATION + 1]; };

Note: Implementation of the program is not sufficient for the maximum grade. I will be grading the quality, efficiency and accuracy of your program code.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.