Académique Documents
Professionnel Documents
Culture Documents
Lab Assignment 2
In this lab assignment you will implement three classes, different methods and use
internal and external method calls.
During this semester we can refine the assignment to define, that a clerk can also
be a client of a bank and that clients can have more than one single account. For
instance, we start with a small application.
Implement the following three classes with the described characteristics:
Please try to adhere to the specified names.
classClerk
Fields:
name
name
phoneNb
type
String
String
Constructor:
takes as parameters the name and phoneNb and initializes the fields
Methods:
CS 212
Page 1 of 4
type
int
float
Client
Clerk
takes as parameters the number, the initial balance and the client and
initializes the fields to these values. Clerk is set to null.
Methods:
name
payIn
takeOff
CS 212
Paramete
rs
float sum
float sum
return
description
void
void
Page 2 of 4
type
String
int
String
Account
Constructor:
The constructor takes the id, the name and the address as parameters and
initializes the fields to these values. It assigns null to the bank account.
Methods:
name
newAccount
Parameter
s
intinitialBal
ance
printClerkPhon
eNb
retur
n
void
void
printBalance
takeOffMoney
float sum
void
void
payInMoney
float sum
void
setClerk
Clerk c
void
CS 212
description
opens a new bank account for this
client with the initial money
prints the name and phone
number of the clerk
(System.out.println)
First the clerk has to be found and
then its phone number.
If no clerk is assigned to the
account, the methods prints:
Sorry, there is no clerk assigned
to your account.
prints the balance of the account
retrieves sum from the bank
account and prints the remaining
balance (printBalance)
pays sum to the bank account and
prints the new balance
(printBalance)
sets the clerk in the account
Page 3 of 4
CS 212
Page 4 of 4