Introduction to Programming
The following learning objectives are covered by this assignment
Learning outcome Assessment criteria
1 have understood and learnt the
programming language syntax and
can create and/or recognise syntactically
correct code for specified aspects of the
programming language syntax and
2 write simple code to demonstrate
appropriate use of differing aspects
writes code for a precisely specified
3 design and program a solution to a
designs, implements and tests a program
to solve a given problem
When reading this assignment brief DON’T PANIC it has been written so that it provides a challenge
for the strongest programming students but also enables other students to demonstrate they can
create simple Java programs.
Delboy trotter’s Second-hand Car Dealership
Delboy Trotter has a second hand car business wherehe buys and sells used cars. His business is
growing and he wants to replace his paper based system for keeping track of his car stock and sales:
He keeps basic information about each car he has bought and sold e.g. make, model, the price
Delboy paid for it and the price he sold it for. Typical data would be
Car Information Typical data
registration number MM03KBU
price paid 1900.00
price sold for 2199.50
When he buys a car the ‘price sold for’ will be 0.00 (zero)
This entity is a list of all cars he has bought andsold. It also provides all the functionality required to
maintain the collection of cars. The expected functionality for this class is shown on the next page.
Page 3 of 6
System user requirements (functionality / methods)
User Requirements Set A Max mark
1. Car records:
a. add a new car
b. for a given registration number print the car’s details
c. print a list all cars that are for sale (i.e. where the price paid for is
User Requirements Set B
2. Car records:
a. return a car with a particular member registration number
b. search for and print all cars of a particular make e.g. all Fords
c. remove a car with a particular car registration number
User Requirements Set C
3. Car records
a. search for and print all cars of a particular make and model (e.g.
all Ford Mondeo’s) that are for sale
b. print a list of all cars that have been sold (donot include those for
sale) and the profit made on each. Also print the total profit made
on all sales.
User Requirements Set D
4. Car records (For this you will need to work withdates)
a. modify the car class so that you can record the date of sale.
b. print a list of all cars sold in a particular month and year and the
total profit made..
If you have been referred then your mark will be capped at 40% but if you have been deferred your
mark is not capped so it is worth attempting as much of this as possible.
Page 4 of 6
Some guidelines to creating the software
You are obviously going to need a class to model the car so you should create this first. For this
•identify and define the fields required, these canbe found in the scenario.
•create a parameter constructor to simplify the creation of car objects
•create accessor and mutator methods for each field
•create a method that prints the objects details onone line, this will be useful when you want to
print a list of members or cars.
Once you have created the car class you can then create the stock class which will be used to
maintain the collection of cars.
•define a field of type ArrayList for the cars
•create a constructor that will create/instantiate the ArrayList
•create methods to implement the functionality on page 3 – each user requirement would be a
separate method in this class
Functionality set 4 requires you to work with datesI recommend that you investigate the Java library