The Java TM Tutorial

| Start of Tutorial > Start of Trail > Start of Lesson | Search

Trail: Putting It All Together
Lesson: BINGO!

## The Classes in bingo.shared

> The following lists and describes all the classes in the `bingo.shared` package.
> - `Registrar`-- an interface

>   This interface is implemented by `bingo.game.RegistrarImpl` and defines the three remote methods supported by the Game application that can be called by the Player. One method is called by the Player to register for a game, one is called by the Player to claim BINGO, and one is called to get status from the Game.

> - `Constants`-- an interface that contains a collection of game constants.

>   One constant define in this file is the port number used by the Game to broadcast packets to the Player. Three other constants are group names used to categorize the broadcast packets into three types of information: balls, player status updates, and game status updates.

> - `ErrorMessages`-- this class contains a collection of static methods that both the Game and the Player can call to print error messages.

> - `BingoBall`-- a BINGO ball.

>   Used extensively by `Card` and `BallAnnouncer`.

> - `Card`-- a BINGO card.

>   Each space on the card contains a `BingoBall`. Created and signed by the Game.

> - `Ticket`-- an instance of this class is created by the Registrar when a Player registers and returned to the Player.

>   It contains the Player's ID, cards, and other information needed by the Player to play.

> - `PlayerRecord`-- represents a Player.

>   Used by the `Registrar` and `PlayerInfoPane` to keep track of players.

> - `Answer`-- returned to the Player when the Player claims BINGO.

>   This class informs the Player whether or not they actually won.

> - `OverallStatusPane`-- implements the Game status UI.

>   This window creates a `LightBoardPane`, `PlayerInfoPane`, and a `GameStatusLabel`. This is general enough that it could be used by the Player or another application.

> - `PlayerInfoPane`-- used by the Game to display the players that are registered in this game.

>   This Pane is a `PlayerListener` and uses a `PlayerListenerThread` to listen for player status updates on the `MulticastSocket`.

> - `PlayerInfoModel`-- controls the content of the table that lists the currently registered players.

> - `GameStatusLabel`-- used by the Player and by the Game to display game status.

>   This Label is a `GameListener` and uses a `GameListenerThread` to listen for game status updates on the `MulticastSocket`.

> - `LightBoardPane`-- used by the Player and by the Game to display the balls that have been announced in this game.

>   This particular status pane works differently than the `PlayerInfoPane` and `GameStatusLabel`. This Pane is not a `BallListener` and doesn't use a `BallListenerThread`, but must be created and informed of announced balls by a `BallListener` using a `BallListenerThread`. This is because the information is needed at a higher level in each program (the `BallAnnouncer` throws an end-of-game ball which has implications for the rest of the program).

> - `Parameters`-- an abstract class that manages program parameters.

>   Both the Player and the Game applications have concrete subclasses of this class to manage their program parameters.

> - `Utilities`-- a class with a couple of useful methods for positioning Swing components.

>   This class is only used by the Player application, but could be used by other applications.

> - `Listener`-- an empty interface whose sole purpose is to be a superinterface to `BallListener`, `PlayerListener` and `GameListener`.

> - `ListenerThread`-- the abstract superclass of `BallListenerThread`, `PlayerListenerThread`, and `GameListenerThread`.

>   This class is a subclass of `Thread` provides a constructor which must be called by its subclass's constructors. Additionally, this class provides the `stopListening` method for its subclasses.

> - `BallListener`-- an interface that defines the methods a class must implement in order to listen to balls as they are announced.

>   This interface is implemented by `bingo.shared.OverallStatusPane` and `bingo.player.Player`. A `BallListener` uses a `BallListenerThread` to listen to a `MulticastSocket` for announced balls. The thread notifies its `BallListener` of interesting activities on the socket.

> - `BallListenerThread`-- a subclass of `ListenerThread` that receives balls from the `MulticastSocket` as they are sent by the Game.

>   This thread is created with a `BallListener` which is informed of each ball as it is announced.

> - `PlayerListener`-- an interface that defines the methods a class must implement in order to listen to player status updates.

>   A `PlayerListener` uses a `PlayerListenerThread` to listen to a `MulticastSocket` for player status messages. The thread notifies its `PlayerListener` of interesting activities on the socket. `PlayerInfoPane` implements this interface and creates a `PlayerListenerThread` for listening.

> - `PlayerListenerThread`-- a subclass of `ListenerThread` that gets player status updates from the `MulticastSocket` as they are sent by the Game.

>   This thread is created with a `PlayerListener` which is informed of status messages as they are received.

> - `GameListener`-- an interface that defines the methods a class must implement in order to listen to game status updates.

>   A `GameListener` uses a `GameListenerThread` to listen to a `MulticastSocket` for game status messages. The thread notifies its `GameListener` of interesting activities on the socket. `GameStatusLabel` implements this interface and creates `GameListenerThread` for listening.

> - `GameListenerThread`-- a subclass of `ListenerThread` that gets game status updates from the `MulticastSocket` as they are sent by the RingMaster.

>   This thread is created with a `GameListener` which is informed of status messages as they are received.

> - `BingoException`, `NoMoreBallsException`-- exceptions for the BINGO game.

| Start of Tutorial > Start of Trail > Start of Lesson | Search