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:
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.