// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package test;

import java.util.ArrayList;
import java.util.List;

public class Game {
    private static Game instance = null;
    private List moves;
    private List players;
    private Game() {
        moves = new ArrayList();
        players = new ArrayList();
    }
    public static synchronized Game getInstance() {
        if(instance == null) {
            instance = new Game();
        }
        return instance;
    }
    public void addPlayer(String player) {
        players.add(player);
    }
    public void doMove(String move) {
        moves.add(move);
    }
    public List getAllMoves() {
        return moves;
    }
    public boolean isEnough() {
        return players.size() == 2;
    }
    public String playerToMove() {
        return (String)players.get(moves.size() % players.size());
    }
}
