/* * RedmondScoreboard.java * * Created on April 4, 2002, 1:41 PM */ /** * * @author redmond * @version */ public class RedmondScoreboard { /** Creates new RedmondScoreboard */ public RedmondScoreboard() { } /** * @param args the command line arguments */ public static void main (String args[]) { ScoreBoard mySB = new ScoreBoard(); System.out.println("mySB: " + mySB.toString()); String tempTeam; /// find out who wins the jump ball System.out.println("Who gets the ball first? (L for La Salle or V for Visitor)"); char team = SavitchIn.readLineNonwhiteChar(); // ensure valid answer while ((team != 'l') && (team != 'L') && (team != 'v') && (team != 'V') ) { System.out.println("Who gets the ball first? (L for La Salle or V for Visitor)"); team = SavitchIn.readLineNonwhiteChar(); } String teamBall; String teamDefense; // determine team with ball if ((team == 'l') || (team == 'L')) { teamBall = mySB.getHomeName(); teamDefense = mySB.getAwayName(); } else { teamBall = mySB.getAwayName(); teamDefense = mySB.getHomeName(); } char answ = 'N'; while (answ == 'N') { System.out.println("What happens with " + teamBall); System.out.println("1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal; 4) No Points"); int choice = SavitchIn.readLineInt(); // ensure valid input while ((choice < 1) || (choice > 4)) { System.out.println("What happens with " + teamBall); System.out.println("1) One Free Throw Made; 2) 2-pt Field Goal; 3) 3-pt Field Goal; 4) No Points"); choice = SavitchIn.readLineInt(); } switch (choice) { case 1: mySB.makeFoulShot(teamBall); break; case 2: mySB.makeTwoPoint(teamBall); break; case 3: mySB.makeThreePoint(teamBall); break; } // swap who has the ball tempTeam = teamBall; teamBall = teamDefense; teamDefense = tempTeam; System.out.println("mySB: " + mySB.toString()); // see if game continues System.out.println("Is the game over (Y or N)?"); answ = SavitchIn.readLineNonwhiteChar(); // ensure valid answer while ((answ != 'n') && (answ != 'N') && (answ != 'y') && (answ != 'Y') ) { System.out.println("Is the game over (Y or N)?"); answ = SavitchIn.readLineNonwhiteChar(); } // convert to upper case for consistency if (answ == 'n') { answ = 'N'; } } // end while System.out.println("Game over"); System.out.println("mySB: " + mySB.toString()); } }