public class GamePool
extends java.lang.Object
jpleal@fc.up.pt
Constructor and Description |
---|
GamePool()
Create an instance with a timer to schedule the remotion of expired games.
|
Modifier and Type | Method and Description |
---|---|
(package private) java.lang.String |
createGame(java.lang.String name)
Create a game master for the game with given name
|
(package private) java.util.List<GameInfo> |
getAvailableGameInfos()
Produces a list with information on games
still available to human players
|
(package private) GameMaster |
getGameMaster(java.lang.String gameId)
The game master with given id
|
(package private) java.util.List<java.lang.String> |
getGameNames() |
(package private) void |
removeExpiredGames()
Remove all games in this pool that have already expired.
|
(package private) void |
reset()
Resets GamePool's fields to enable unit testing
on the
Manager singleton. |
GamePool()
java.util.Timer.scheduleAtFixedRate()
and
use as rate the GameMaster.getExpirationtime()
.java.util.List<java.lang.String> getGameNames()
java.lang.String createGame(java.lang.String name) throws CardGameException
name
- of gameCardGameException
- if game is unknownGameMaster getGameMaster(java.lang.String gameId) throws CardGameException
gameId
- of intended gameCardGameException
- if id is invalidjava.util.List<GameInfo> getAvailableGameInfos()
void removeExpiredGames()
remove()
method from the iterator rather than
a method from the collection itself. Otherwise,
a ConcurrentModificationException
may be raised.
Use a regular for
rather than an extended loop to
have access to the iterator instance.void reset()
Manager
singleton.
This method must only be used during testing
and shoudn't be public.