Skip to content

mebestaca/DriveMasters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 

Repository files navigation

Assignment 2: Abstract Class and Inheritance

Submitted By:

Marc Edison Estaca
Paule, Lexter
Realica, Justin
Dang, Dylan

Date Completed

October 26, 2025

Scenario:

A local company, DriveMasters, has hired you to implement a system to manage their vehicle inventory more efficiently. They want a system that allows both employees and customers to find, list and purchase vehicles. The company has provided you with a data file containing a sample list of vehicles. The data file contains five types of vehicles: Sedan, SUV, Hatchback, Pickup Truck and Hybrid cars. Each vehicle is uniquely identified using CarID, and information about each type of vehicle is described in the formatting section.

Vehicle Details

Data Formatting

  • Each of the following vehicle types is represented differently in the supplied vehicles.txt file.
  • Each line in the file represents a different vehicle and each piece of information for a vehicle is separated by a semi-colon.
  • The first digit of the CarID indicates the type of the vehicle. Each CarID is 9 digits long.

Sedan

  • The first digit of the CarID for Sedan is 1.
  • Sedan have: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;TrunkSize
  • The trunk sizes can be either:
    • Large/spacious trunk (L),
    • Small (S)
    • Moderate (M).
  • Each Sedan is represented in the vehicles.txt file as follows: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;TrunkSize Example: 121587921;Sedan;Luxury;180;50.0;5;2020;AWD;25000;8;L

Hatchback

  • The first digit of the CarID for hatchback is 2.
  • Hatchback have: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;HatchType
  • Hatch Type can be either:
    • Standard Liftgate (S),
    • Split Liftgate(T)
    • Power Liftgate (P)
  • Each Hatchback is represented in the vehicles.txt file as follows: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;HatchType Example: 263914872;Hatchback;Economy;160;45.0;5;2019;FWD;18000;10;P

SUV

  • The first digit of the CarID for SUV is 3.
  • SUV have Drivetrain: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity
  • The Drive terrain can be either:
    • All wheel drive (AWD)
    • Four wheel drive (4WD)
    • Front-Wheel Drive (FWD)
  • Each SUV is represented in the vehicles.txt file as follows:
  • CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity Example: 374512039;SUV;Compact;160;70.0;7;2018;AWD;35000;4

Hybrid

  • The first digit of the CarID for Hybrid is 4 or 5.
  • Hybrid have Powertrain Type: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;PowerTrain; ElectricRange;
  • Power Train can be either:
    • Series Hybrid (E)
    • Parallel Hybrid (A)
    • Plug-in Hybrid (PHEV)
  • Each Hybrid is represented in the vehicles.txt file as follows:
  • CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;PowerTrain ElectricRange; Example: 596387204;Hybrid;Crossover;180;45.0;5;2022;AWD;28000;6;A;40

Pickup Truck

  • The first digit of the CarID for Pickup Truck is 6.
  • Pickup Truck have Cargo Beds: CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;CargoBeds; CargoCapacity
  • Cargo Beds can be either:
    • Short Bed (SB)
    • Extended Bed (EB)
    • Dump Bed (DB)
  • Each Pickup Truck is represented in the vehicles.txt file as follows:
  • CarID;VehicleType;Subtype;Speed;Fuel;Seats;Year;Drivetrain;Price;Quantity;CargoBeds; CargoCapacity Example: 641289354;Pickup Truck;Full-Size;140;80.0;2;2021;4WD;30000;10;EB;1500

Program Details

The fact that the data formatting is different for each type of vehicles adds a level of complexity to program development. Creating a class hierarchy is required:

  • Determine the attributes that are shared between the vehicles types and create a Vehicle class containing them. NOTE: The Vehicle class cannot be instantiated and must be a super-class.
  • Create the following classes such that each one inherits the Vehicle class and is located in the program’s problemdomain folder:
    • Sedan
    • Hatchback
    • SUV
    • Hybrid
    • Pickup Truck
  • Ensure that each of these classes has a user-defined constructor that assigns the appropriate attributes.
  • Override the toString() method in each one of these classes, so that the data is in a human readable form.
  • The attributes should be displayed using vertical headers. Along with the functionality mentioned above, include the following methods in your program:
  • A method that parses the vehicles.txt file into a single list.
    • The list must be able to contain all vehicle types (sedan, hatchback, suv, hybrid and pickup truck).
    • Use the first digit of the CarID to determine what valid type of vehicle needs to be created (see the Vehicle Details section for more information).
  • A method that allows a customer to puchase a vehicle.
    • The customer is prompted to enter the CarID of a vehicle. If the entered CarID does not match, the program will inform the customer with an error message. If the CarID matches, the program checks the vehicle’s availability. If there is a vehicle available, the available count will be decremented and the vehicle information will be displayed. Otherwise, the customer will be informed the vehicle is not available.
  • A method that prompts the customer to enter a vehicle type. The program performs a case-insensitive search of vehicles that have the same vehicle type, and displays them.
  • A method that prompts the customer to first enter a vehicle type, then enter a respective sub type. The program performs a case-insensitive search of vehicles that have the same vehicle type and sub type, and displays them.
  • A method that prompts a user to enter a number, and the program then displays that number of random vehicles. The vehicles can be of any type.
  • A method that persist vehicles stored in the list back to the vehicles.txt file in the proper (original) format when user choses to exit the program.

Sample Output:

Sample Output 1 Sample Output 2 Sample Output 3 Sample Output 4 Sample Output 5 Sample Output 6 Sample Output 7 Sample Output 8 Sample Output 9 Sample Output 10

About

Group Assignment 2 for Object Oriented Programming 2 at Southern Alberta Institute of Technology. The topic is about abstract classes and inheritance but our group decided to go beyond the topic. We designed and implemented clean architecture throughout the project, utilizing advanced programming concepts to the best of our abilities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages