Assignment2021 1 2-1
Assignment2021 1 2-1
OBJECTIVE
This assignment is mainly about “design/implementation”.
You should be implementing a simulation of part of a drinks machine. This
simulation will follow the requirements that have been defined in coursework 1
and follow the use cases that you defined. This simulation will not be a full
implementation of the original requirement but a will only implement the coin
handling part of the machine. All the UI code is provided for you, so there is no
GUI programming required. You are strongly encouraged to start this work as
soon as possible.
Deadline Day & Date & Time 9th of December 2021 at 23:00 (11 PM)
Submission Mode Electronic submission
Learning outcome assessed 1. Realise the problems in
designing and building
significant computer systems
2. Understand the need to design
systems that fully meet the
requirements of the intended
users
3. Be able to apply these principles
in practice
4. Be able to demonstrate how to
effectively implement an O-O
design in an O-O language such
as Java or Python.
Submission necessary in order No
to satisfy Module requirements
Purpose of assessment To assess the students ability to analyse
a problem and implement it in code
1 of 3
Description of problem
Produce code to support a drinks machine simulation in Java using the existing drinks
machine simulation code as a base. (This has been made available to you as an
Eclipse project).
NOTE You only need to fulfil the requirements of this coursework not the whole
of the requirement detailed in coursework 1.
The will need to implement the following
Coin handling
Accept coin codes and credit the user with the correct credit. If the user presses
reject, return the users remaining credit. On return of credit the machine should return
the change using the highest coin denominations first coins if possible, for example
£1.50 can be returned as a pound coin plus one fifty pence coin. However, if there are
no one pound coins in the machine, this may not be possible and lower denominations
will be needed. Your code will have to handle this logic. If some of the coin levels
are low, it might not be possible to pay out all the change and the balance will be left
as a non-zero value.
For the submission, you should only change the code in CoinHandlerManager.java.
CoinHandlerManager.java
Handling coins in
String code=machine.getCoinHandler().getCoinKeyCode();
This method returns either a valid coin code or null of no new coin has
been entered. You get the actual coin definition from the code, there is a
method in Coin.java, called getCoinFromCode, you should use this method to
find out information about the coin. Look at Coin.java to undyerstand the
Coin definition. Each name has a name, a code and a worth. For example a
pound coin has a code of ‘ef’, a value of 100 and its name is 100p.
2 of 3
Coin.getAllcoins()
You need to use these every time you wish to change the balance.
Apart from the balancing getter and setter, and the public methods from
Coin.java you should use ONLY the following methods in your final code for
returning change.
machine.getCoinHandler().dispenseCoin(int code)
This pays back one coin of the given code to the customer.
machine.getCoinHandler().coinAvailable(int code)
Marking criteria
This code will be marked using automatic testing. Different currencies will
be tested. Low coin level will be tested when paying back change. The
structure and format of the code will NOT be marked for this assignment,
however you are strongly encourage to format and comment your code
correctly.
3 of 3