Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CSE114 Fall 2015
Lab Exercise of Week 8
Object-Oriented Programming:
A Banking System
Chen-Wei Wang
Deadline
A large part of the midterm test (15% of your course grade) next Friday, October 30 will be based on
this lab exercise. This lab exercise is similar to the previous exercise of student registration system. You
are strongly advised to complete this exercise in order to answer questions about it in the (closed-book)
midterm test.
Problem
A banking system has a number of bank clients. Each client has a unique client id (which gets first
assigned when they are accepted as a client by the bank), a first name, a last name, a contact phone
number, a mailing address, and a list of bank accounts. Each account has a unique account id (which gets
first assigned when it is opened), its associated owner (i.e., a bank client), and the history of transactions
(from which the balance of the account can be calculated). Each transaction has an id, a type (deposit
or withdraw), and the amount of money involved. The banking system may accept a new client, in which
case their list of accounts is initialized to be empty. The banking system may also open a new account for
an existing client, in which case the list of transactions is initialized to be empty. Given a valid account
id, a client may deposit money into that account, which adds a new deposit transaction to that account’s
list of transactions. Similarly, given an account id, a client may withdraw money from that account,
which adds a new withdraw transaction. Furthermore, at the level of each client, given two valid account
id’s, a client may transfer money between two of their accounts, which adds a withdraw transaction to
the first account and adds a deposit transaction to the second account. Each of a client’s accounts may
be inquired about its current balance (by considering its history of deposit and withdraw transactions).
At the level of the banking system, given two valid client id’s and two valid account id’s, a client may
transfer money from one of their accounts to one of the accounts of another client.
1
Your Tasks
1. Translate the entities, attributes, and behaviours that are indicated in the above problem statement
into classes, attributes, constructors, mutator methods, and accessor methods in Java.
2. Create a separate class BankingSystemTester that simulates the possible scenarios by creating
instances of your classes and calling methods on them. Use breakpoints and debugger in Eclipse to
monitor the changes on variables at runtime. For example:
– Bill is accepted as a new client of the bank.
– Steve is accepted as a new client of the bank.
– Bill opens a first account in the bank.
Print out the balance of Bill’s first account.
– Bill opens a second account in the bank.
Print out the balance of Bill’s second account.
– Bill opens a third account in the bank.
Print out the balance of Bill’s third account.
– Steve opens a new account in the bank.
Print out the balance of Steve’s first account.
– Bill deposits 2 millions into his first account.
Print out the balance of Bill’s first account.
– Bill deposits 3 millions into his second account.
Print out the balance of Bill’s second account.
– Bill withdraws 0.5 million from his first account.
Print out the balance of Bill’s first account.
– Bill transfers 0.5 million from his second account into his third account.
Print out the balances of Bill’s second and third accounts.
– Steve deposits 2 millions into his account.
Print out the balance of Steve’s account.
– Bill transfer 1 million from his second account into Steve’s account.
Print out the balances of Bill’s second account and Steve’s account.
2