0% found this document useful (0 votes)
20 views

Assignment2021 1 2-1

Uploaded by

flannerywangliu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Assignment2021 1 2-1

Uploaded by

flannerywangliu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

COMP201: Software Engineering I

Assignment 1.2 (2021/22)


(100% mark for Assignment 1.2 is 5% of COMP201 grade)
Deadline for Assignment 1.2: 9th of December 2021, 23:00

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.

The purpose of this exercise is to understand the challenges of implementing a


design from requirements and the state modelling required. This code will be
implemented using a simulated version of the hardware, it would then be
possible later to implement a real drinks machine be replacing the simulation
code with software drivers connected to real hardware.

Assignment number 1 of 2 (part 2)


Weighting 5%
Assignment Circulated date provided to class 27/9/2021

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

See end of document


Marking criteria
Late Submission Penalty Standard UoL Policy

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.

All the code you will implement is done as part of CoinHandlerManager.java.

Notes, very important to gain full marks read the following

For the submission, you should only change the code in CoinHandlerManager.java.

Testing different currencies


The code can be tested for different currencies by using the drop down box on the
main interface.

CoinHandlerManager.java
Handling coins in

public void handleCoinsIn(IMachine machine) {

String code=machine.getCoinHandler().getCoinKeyCode();

This method is called in a loop at regular time intervals.

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.

The coin definition has getters to retrieve this information.

You can get an array of all the coin definitions by calling

2 of 3
Coin.getAllcoins()

This will be useful when paying back change.

Updating the balance


Each time a new coin is entered the balance should be updated.
machine.getBalance retrieves the current balance

machine.setBalance sets the balance

You need to use these every time you wish to change the balance.

Very important NO NOT STORE THE BALANCE YOURSELF

Returning the change


The other method you must implement is to return the change
public void returnChange(IMachine machine) {
machine.getDisplay().setTextString("Trying to pay change
back");

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)

This returns true if a coin is available to payout of that code, otherwise


it returns false.

For testing purposes you can use the following methods.

public void setHopperLevel(String coinCode,int level)


This is so you can see if your code works correctly, if a coin level is low
when paying back change. Your code should not lock up.

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

You might also like