Week 7 Lab
Week 7 Lab
24 to 28 March 2025
NO VPL
Classes, Objects, Methods and Data Structures
You are tasked with creating a simple system to manage a car dealership inventory.
The system should allow the dealership to store and manage a collection of cars.
Page 1 of 3
CarDealership Class (CarDealership.java):
o Create a CarDealership class that manages a collection of cars using an
ArrayList<Car>.
o The class should have the following methods:
▪ addCar(Car car) – adds a car to the dealership's inventory.
▪ getTotalInventoryValue() – calculates and returns the total value of all
cars in the inventory.
▪ listAllCars() – prints out the details of all the cars in the inventory.
▪ findCheapestCar() – returns the car with the lowest price.
▪ findCarsByMake(String make) – returns an ArrayList of cars that
match a given make.
Page 2 of 3
Sample Output:
Inventory of Cars:
Toyota Corolla 2020 N$ 280000.0
Honda Civic 2019 N$ 220000.0
Ford Mustang 2021 N$ 600000.0
Toyota Camry 2021 N$ 310000.0
Page 3 of 3