FileDocCategorySizeDatePackage
BallAnnouncer.javaAPI DocExample718Tue Dec 12 18:58:42 GMT 2000bingo.game

BallAnnouncer

public class BallAnnouncer extends Thread

Fields Summary
private RingMaster
ringMaster
Constructors Summary
BallAnnouncer(RingMaster ringMaster)

        super("Bingo Ball Announcer");

	this.ringMaster = ringMaster;
    
Methods Summary
public synchronized voidrun()

        BagOfBalls bagOfBalls = (BagOfBalls)(new RandomBag());

        while (ringMaster.gameInProgress()) {
	    if (!ringMaster.isCheckingForWinner()) {
	        try {
		    ringMaster.announceBall(bagOfBalls.getNext());
	        } catch (NoMoreBallsException e) {
		    ringMaster.setGameOver();
	        }
	    }

	    try {
		wait(ringMaster.getGameParameters().getDelay());
	    } catch (InterruptedException e) { }
        }