[SOLVED] Java Lab 8 page 1

$25

File Name: Java_Lab_8_page_1.zip
File Size: 160.14 KB

5/5 - (1 vote)

Lab 8 page 1

QQuueeeennMMaarryy
UUnniivveerrssiittyyooffLLoonnddoonn

SScchhoooollooffEElleeccttrroonniiccEEnnggiinneeeerriinnggaannddCCoommppuutteerrSScciieennccee

EBU5304: Software Engineering

Lab 8: Design Principles

(This lab exercise is not assessed)

Consider the following Java interface type:

interface Logger

{

public void log(String name, int change);

public String display(String name, int number);

}

The idea is that an object of a class which implements this interface can be used to keep a

record or log of the changes made to a set of named numerical values.The first argument to

the two methods is set to the name of a particular numerical value.The method log is called

whenever a named numerical value is changed, its second argument should be set to the value

of the change.The method display is used to obtain the record of changes made, with its

second argument set to the number of changes to be displayed.

For example, if we have an object of type Logger, and the following method calls have been

made on it in this order:

log(John,3), log(Mary,5), log(John,-4), log(John,10),

log(Fred,14), log(John,-2), log(John,7), log(Mary,5)

then calling display(John,3) on the object will return the String value +10 -2 +7.

1) Write a class which implements this interface.You will need to choose a suitable
internal representation for objects of that class so that they give the required behaviour.

2) Write ANOTHER class which implements this interface.It should differ from the first
class by having a different internal representation, but its external behaviour should be

the same as the first class.

3) Modify the code you wrote for your previous lab exercises so that bank accounts are

linked to a Logger object.Whenever funds are deposited or withdrawn from an

account, there should be a call of the method log on the Logger object, with its first

argument set to the name of the account holder and its second argument set to the amount

by which the balance of the account has changed.

Consider the extent to which you have been able to keep to the design principles covered in the

lectures in making the modifications asked for in question 3).

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Java Lab 8 page 1
$25