← Back to Week 5
Workshop 4w — Full Workshop Project

Car Dealership

Build a console-based dealership inventory app across 5 cooperating classes — this is the Week 5 workshop

The Workshop

Build a command-line app for a used-car dealership. Load the dealership and its inventory from a pipe-delimited file, then offer a menu where the user can search vehicles by price, make/model, year, color, mileage, or type — or list all vehicles, add a new one, or remove one. Save back to the file after every change.

Five classes work together: a data class for a single Vehicle, a container class for the Dealership, a file-handling class, a UI class, and a tiny Program with main in it.

Architecture — 5 Classes
Vehicle
A single vehicle — VIN, year, make, model, type, color, odometer, price.
Dealership
Dealership name/address/phone plus an ArrayList<Vehicle>. All search/add/remove methods live here.
DealershipFileManager
getDealership() reads the file and returns a Dealership. saveDealership(d) writes it back.
Owns Dealership
UserInterface
Handles all I/O. Prints menus, reads input, and calls Dealership methods. Instantiates the Dealership itself (not Program).
Program
Tiny entry point. main() creates a UserInterface and calls display() — that's it.
UserInterface owns the Dealership, not Program. The workbook calls this out specifically because the architecture is designed for a future feature where one application talks to multiple dealerships. Keeping ownership inside the UI makes that easier later.
Inventory File Format

One pipe-delimited file. Line 1 is the dealership info; every line after is one vehicle.

inventory.csv
D & B Used Cars|111 Old Benbrook Rd|817-555-5555
10112|1993|Ford|Explorer|SUV|Red|525123|995.00
37846|2001|Ford|Ranger|truck|Yellow|172544|1995.00
19264|2005|Honda|Civic|car|Silver|110987|3995.00
Columns per vehicle: VIN | year | make | model | type | color | odometer | price
Save after every change. Add a vehicle → save the file. Remove a vehicle → save the file. Don't wait until exit — if the program crashes, the change is lost.
Menu — Numbered Options
Phased Build — Don't Do It All At Once
  1. Empty classes first. Build Vehicle and Dealership with constructors and getters/setters only. Make every search method return null for now. Verify the project compiles before writing any logic.
  2. File reader. Implement DealershipFileManager.getDealership() — read the file, parse the first line into a Dealership, parse each remaining line into a Vehicle and add it. Leave saveDealership() empty for now.
  3. UI skeleton. Build UserInterface. display() calls init() which loads the dealership via DealershipFileManager. Show the menu loop. Implement processAllVehiclesRequest() first to verify the load worked.
  4. Wire up Program. In Program.main(), instantiate UserInterface and call display(). Run it — you should see your inventory print.
  5. Fill in the rest. Implement each search method one at a time, then add/remove. Call saveDealership() after every add and every remove.
Concepts You'll Use
Flow
1. Empty classes Vehicle, Dealership, FileMgr, UI, Program
2. Starter inventory file 3-4 vehicles to test with
3. getDealership in FileMgr read + parse
4. UI: display + init + listAll first working screen
5. Wire main → UI.display()
6. Run — see your vehicles
7. Each search method one at a time, test each
8. Add / Remove + saveDealership
9. Test every menu option
10. Push to GitHub

Workshop 4w — Car Dealership

← Blackjack