CS 157 Spring 2002 Assignment
10 – Debugging using the Sun Studio Java Debugger 50
points
Assigned: 04/03/2003
Due: 04/09/2003 at the start of
class
IT
IS NOT APPROPRIATE TO GET ANSWERS FROM CLASSMATES ON THIS ASSIGNMENT!!
WORK INDIVIDUALLY !!!!!
Pre-Lab (Do Before Lab): None
Main Assignment:
There is a buggy version of a
program described below, named RunATMBuggy.java, available on my WWW page. It
uses an Account class, and some other banking classes, and RedmondMsgIn.java,
also available on my WWW page. Copy forDebugAssign.zip to where you like to
work. Unzip it (double click and make appropriate choices). Set up the IDE to use these program files.
Compile and try it out. This version has one or more bugs – they should be in
the RunATMBuggy class.
1)
Use
the debugger to track down the bug(s), by stepping and displaying values for
variables. Don’t find bugs in other ways, you want to learn how to use the
debugger.
2)
Hand
in or e-mail me (redmond@lasalle.edu)
·
a
clear complete description of what the bug(s) are. Make sure you describe very
clearly (use line numbers to help). (Or, you may send me a fixed version of the
program, IF you clearly mark with comments exactly what your
fixes were AND you make them stand out. (e.g. you could use **********’s or ##########’s to draw
attention to your comments.) Your few changes will be HARD for me
to find within the program if you just make the fixes and don’t draw attention
to them. ). Also, if you send/ give me
a fix, make sure you give me a complete set of files with the correct folder
structure so I can see your fix work.
3) Note that everything below
was taken from a description of a task for a previous class. It is not
your task. Your task is to use the debugger to find the problem(s)!! The skills
learned here can also be useful for debugging your own programs.
The
Description of What the Program Was Supposed to Do:
A simplified Account class
has been provided. Create a (very)
simplified client program, as illustrated below. The program should create an
array of 15 accounts, and as long as the user wants to keep playing, prompt
them for an account number and PIN, and when they give a valid account number /
PIN, ask them if they want to Deposit, Withdraw, or Check account balance, or
quit. After each account quits, see if the general user says to quit (see
below). When quitting entirely, show all 15 account balances.
NOTE: Your account numbers may not be the same as mine, due
to random account number generation.
Sample Interaction with the user when the program is
correct (157 Students – much of this interaction occurs using dialog boxes –
capability provided by calls to RedmondMsgIn methods):
In
this dummy bank there are only 15 valid accounts. Work with these:
Acct:
30719 PIN: 7611 Bal: 0.0
Acct:
17349 PIN: 8586 Bal: 0.0
Acct:
14059 PIN: 6237 Bal: 0.0
Acct:
68320 PIN: 735 Bal: 0.0
Acct:
54417 PIN: 195 Bal: 0.0
Acct:
47714 PIN: 6664 Bal: 0.0
Acct:
73149 PIN: 2430 Bal: 0.0
Acct:
93005 PIN: 439 Bal: 0.0
Acct:
13643 PIN: 9280 Bal: 0.0
Acct:
40658 PIN: 6814 Bal: 0.0
Acct:
18903 PIN: 6121 Bal: 0.0
Acct:
16743 PIN: 6382 Bal: 0.0
Acct:
45856 PIN: 4334 Bal: 0.0
Acct:
02554 PIN: 2017 Bal: 0.0
Acct: 35607 PIN: 169 Bal: 0.0
Please enter your account number: 13643
Please enter your PIN: 9280
Choose:
1)
1) Deposit 2)
Withdrawal 3) Account Balance 4) Quit
1
Please
enter the deposit amount (between 1 and
2000) 2000
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
3
Account:
Acct: 13643 PIN: 9280 Bal: 2000.0
Choose:
1)
1) Deposit 2)
Withdrawal 3) Account Balance 4) Quit
2
Please
enter the withdrawal amount (between 20
and 200) 200
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
3
Account:
Acct: 13643 PIN: 9280 Bal: 1800.0
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
5
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
4
Should the system stay up? y
Please enter your account number: 13333
Please enter your PIN: 3333
Please enter your account number: 14059
Please enter your PIN: 6237
Choose:
1) Deposit 2) Withdrawl 3) Account Balance
4) Quit
2
Please
enter the withdrawal amount (between 20
and 200) 50
ERROR - cannot withraw an amount more than in account
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
1
Please
enter the deposit amount (between 1 and
2000) 200
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
3
Account:
Acct: 14059 PIN: 6237 Bal: 200.0
Choose:
1) Deposit 2) Withdrawal 3) Account Balance
4) Quit
4
Should the system stay up? n
Times
up!
Updated
accounts:
Acct:
30719 PIN: 7611 Bal: 0.0
Acct:
17349 PIN: 8586 Bal: 0.0
Acct:
14059 PIN: 6237 Bal: 200.0
Acct:
68320 PIN: 735 Bal: 0.0
Acct:
54417 PIN: 195 Bal: 0.0
Acct:
47714 PIN: 6664 Bal: 0.0
Acct:
73149 PIN: 2430 Bal: 0.0
Acct:
93005 PIN: 439 Bal: 0.0
Acct:
13643 PIN: 9280 Bal: 1800.0
Acct:
40658 PIN: 6814 Bal: 0.0
Acct:
18903 PIN: 6121 Bal: 0.0
Acct:
16743 PIN: 6382 Bal: 0.0
Acct:
45856 PIN: 4334 Bal: 0.0
Acct:
02554 PIN: 2017 Bal: 0.0
Acct:
35607 PIN: 169 Bal: 0.0