CS 157 Spring 2002                          Assignment 10 – Debugging using the Forte Java Debugger                   50 points

 

Assigned: 04/19/2002

Due: 04/25/2002 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 RedmondScoreboardBuggyDemo.java, available on my WWW page. It uses a revised ScoreBoard class, named ScoreBoardBuggy.java, also available on my WWW page. Copy both to your disk, and set up Forte to use these program files. Compile and try it out. This version has one or more bugs – they may be in either the ScoreBoardBuggy class or in RedmondScoreboardBuggyDemo.

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)  two things:

A)     a clear complete description of what the bug(s) are. (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. )

B)      the answers to the following questions:

a.        what is the value for secondsLeft in endPeriod immediately after the score becomes 12-10 (before that score is even displayed)? (using example test case, prior to any fixes)

b.       Does the call to nextPeriod on line 141 get executed when it should at the end of the first period? (after the score becomes 12-10 and time runs out) (using example test case, prior to any fixes)

c.        What is the value for period in endgame when the second period should have ended?  (using example test case, you may need to fix another bug to get into the second period)

d.       What is the value for homeTeamPoints in getCurrMargin when it is called the first time? (using example test case, you may need to have fixed bugs to get here)

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:

Carry out and manage a basketball game using the ScoreBoard class. Ask the user for team names. Find out who wins the jump ball. Thereafter, teams take turns with the ball. Each possession, a team can score no points, hit one or two free throws, make a field goal, or make a three point shot. Each possession takes some time. (CSC 157 students – this part works, so don’t worry about how much time each possession takes). Keep track of scores, and follow the game through both halves, showing the winner at the end.   (CSC 157 students, 15 minutes were purposely subtracted from the game clock at the beginning of each half, so that this doesn’t take forever). (In the interaction here, by student request, I have interspersed the users responses with the questions – the answers are not bold)

 

Sample interaction with the user when the program is correct:

 

Who is the home team?

La Salle

Who is the away team?

Villanova

At Start of Game: Period: 1  20:00 Score --> La Salle: 0  Villanova: 0

Who gets the ball first? (L for La Salle or V for Villanova

 V

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 0

game1: Period: 1  4:28 Score --> La Salle: 0  Villanova: 0

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 1  4:02 Score --> La Salle: 3  Villanova: 0

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 1

Do they make the second (Y or N)?

 n

game1: Period: 1  3:35 Score --> La Salle: 3  Villanova: 1

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 1  3:16 Score --> La Salle: 5  Villanova: 1

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 1

Do they make the second (Y or N)?

 y

game1: Period: 1  2:55 Score --> La Salle: 5  Villanova: 3

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 1  2:29 Score --> La Salle: 8  Villanova: 3

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 0

game1: Period: 1  2:02 Score --> La Salle: 8  Villanova: 3

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 1  1:43 Score --> La Salle: 10  Villanova: 3

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 1  1:17 Score --> La Salle: 10  Villanova: 6

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 1

Do they make the second (Y or N)?

 y

game1: Period: 1  0:56 Score --> La Salle: 12  Villanova: 6

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 1  0:37 Score --> La Salle: 12  Villanova: 8

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 0

game1: Period: 1  0:10 Score --> La Salle: 12  Villanova: 8

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  5:00 Score --> La Salle: 12  Villanova: 10

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  4:41 Score --> La Salle: 14  Villanova: 10

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 2  4:15 Score --> La Salle: 14  Villanova: 13

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  3:56 Score --> La Salle: 16  Villanova: 13

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

11

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 1

Do they make the second (Y or N)?

 y

game1: Period: 2  3:35 Score --> La Salle: 16  Villanova: 15

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 2  3:09 Score --> La Salle: 19  Villanova: 15

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  2:50 Score --> La Salle: 19  Villanova: 17

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 0

game1: Period: 2  2:23 Score --> La Salle: 19  Villanova: 17

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 2  1:57 Score --> La Salle: 19  Villanova: 20

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  1:38 Score --> La Salle: 21  Villanova: 20

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 2  1:12 Score --> La Salle: 21  Villanova: 23

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  0:53 Score --> La Salle: 23  Villanova: 23

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 2

game1: Period: 2  0:34 Score --> La Salle: 23  Villanova: 25

What happens with La Salle

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 3

game1: Period: 2  0:08 Score --> La Salle: 26  Villanova: 25

What happens with Villanova

0) No Hoop; 1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal

 0

game1: Period: 2  0:00 Score --> La Salle: 26  Villanova: 25

Game over

game1: Period: 2  0:00 Score --> La Salle: 26  Villanova: 25

Winner: La Salle

Margin: 1