Vehicle Inventory Database Adolfo Fabrega Steve Go CSE 331 Data Structures December 9, 2002
Purpose This database manages different kinds of vehicles. A car dealership may consider this database a tool to keep track of their inventory. This project deals with vehicles such as trucks, sedans, and motorcycles.
Trucks Trucks have certain attributes that differ from sedans and motorcycles. Weight (in tons) a truck can hold. (integer) Area of the bed of the truck. (integer)
Sedans Number of doors. (integer) Amount of passengers it can hold. (integer)
Motorcycle Engine capacity. (integer) Warranty guarantor that is needed for all 2-wheelers. (string)
Commands Import. (I) Add. (A) Browse for and display a vehicle with a particular serial number. (B) Display data for all the vehicles in the database. (D) Search for and remove a vehicle with a particular serial number. (R) Save the list of Vehicles in a named file. (S) Quit. (Q)
Implementation Designed the 3 different classes with their own “display” function. They are implemented in separate files with appropriate inclusions of headers. Reading in data proved to be the difficult part because there are many different kinds of vehicles (w/ different attributes) to be read in.
Pseudo-Code of Read In Vehicle *v //pointer while (!eof(input_file)) { Read the type indicator from the file if (type indicator says “TRUCK”) { read in all data for truck v = Truck } else if (type indicator says “SEDAN”) { read in all data for a sedan
Pseudo-Code (con’t) v = Sedan } else if (type indicator says “MOTORCYCLE”) { read in all data for a motorcycle v = Motorcyles } else error in type indicator database.add_vehicle(v);
In the Future... This database could be extended by adding more different types of vehicles such as vans, minivans, SUVs, etc… Can design a more elaborate and intricate GUI for the database w/ more attributes.