Você está na página 1de 4

CS 212 Object-Oriented Programming2013/2014

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:

getter-methods for name and phoneNb

CS 212

German Jordanian University

Page 1 of 4

CS 212 Object-Oriented Programming2013/2014


classAccount
Fields:
name
number
balance
client
clerk
Constructor:

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:

getter methods for: clerk, balance


setter method for clerk
as well as the following two methods

name
payIn
takeOff

CS 212

Paramete
rs
float sum
float sum

return

description

void
void

adds the sum to the balance


takes off the sum from the account (our
account has unlimited credit)

German Jordanian University

Page 2 of 4

CS 212 Object-Oriented Programming2013/2014


class Client
Fields:
name
name
id
address
account

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:

getter-methods for name, address


setter-method for address
getter-method for account
as well as the following 6 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

German Jordanian University

Page 3 of 4

CS 212 Object-Oriented Programming2013/2014


All methods that use the bank account must test, whether the bank account is null
(if (account != null); in case the bank account is null, they do nothing.

CS 212

German Jordanian University

Page 4 of 4