ScoreBoard class and each
began coding it.
public String summarize() method that returns
a string of the form [*] ## - ## [*], where the
star is used to indicate service, and the numbers are the two
player's scores.
javadoc documentation for your program.
ScoreBoard simulation,
we'll go on to the next part. If only a few of you have, we'll
continue to let you work on them.
javadoc comments for someone elses
ScoreBoard class, write an appropriate test program.
import ScoreBoard;
public class TestScoreBoard {
public static void main(String[] args) {
ScoreBoard score = new ScoreBoard(); // The sb we're testing
int i; // For loops
score.reset();
System.out.println("Initial settings: " +
score.summarize());
score.setService(1);
System.out.println("After giving service to player one: " +
score.summarize());
score.setService(2);
System.out.println("After giving service to player two: " +
score.summarize());
// Score a few points for the serving player
for(i = 0; i < 10; ++i) {
score.recordPoint(score.getService());
}
System.out.println("After letting server win a few points: " +
score.summarize());
score.reset();
System.out.println("Reset to: " +
score.summarize());
// More general testing
for(i = 0; i < 10; ++i) {
if (Math.random() < 0.5) {
score.serverWon();
System.out.println("Server won: " + score.summarize());
}
else {
score.serverLost();
System.out.println("Server lost: " + score.summarize());
}
} // for
} // TestScoreBoard
} // TestScoreBoard
ScoreBoard and a TestScoreBoard),
change the rules of the game to those of ping pong
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Wed Nov 5 12:36:36 1997.
This page generated on Wed Nov 5 12:38:46 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu