001    ///////////////////////////////////////////////////////////////////////////////
002    // Copyright (c) 2006, Frank S. Nestel, All Rights Reserved.
003    //
004    // This library is free software; you can redistribute it and/or
005    // modify it under the terms of the GNU Lesser General Public
006    // License as published by the Free Software Foundation; either
007    // version 2.1 of the License, or (at your option) any later version.
008    //
009    // This library is distributed in the hope that it will be useful,
010    // but WITHOUT ANY WARRANTY; without even the implied warranty of
011    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012    // GNU General Public License for more details.
013    //
014    // You should have received a copy of the GNU Lesser General Public
015    // License along with this program; if not, write to the Free Software
016    // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017    ///////////////////////////////////////////////////////////////////////////////
018    
019    package de.spieleck.app.turn;
020    
021    import java.util.LinkedHashMap;
022    import java.util.Collections;
023    import java.util.Iterator;
024    
025    /**
026     * A GameResult is a Game attached with a PlayerGameScore for
027     * every Player. 
028     * 
029     * @see PlayerGameScore
030     * @see Game
031     * @see Player
032     *
033     * <p><a href="$URL: https://svn.sourceforge.net/svnroot/jtourney/src/de/spieleck/app/turn/GameResult.java $">$URL: https://svn.sourceforge.net/svnroot/jtourney/src/de/spieleck/app/turn/GameResult.java $</a></p>
034     *
035     * @author Frank S. Nestel
036     * @author $Author: nestefan $
037     * @version $Revision: 2 $ $Date: 2006-03-20 14:33:27 +0100 (Mo, 20 Mrz 2006) $ $Author: nestefan $
038     */
039    public class GameResult
040        implements Game
041    {
042        private int id;
043    
044        private LinkedHashMap<Player,PlayerGameScore> scores;
045    
046        public GameResult(int id)
047        {
048            this.id = id;
049            scores = new LinkedHashMap<Player,PlayerGameScore>();
050        }
051    
052        public void add(Player p, PlayerGameScore pgs)
053        {
054            scores.put(p, pgs);
055        }
056    
057        public boolean contains(Player p)
058        {
059            return scores.keySet().contains(p);
060        }
061    
062        public int size()
063        {
064            return scores.size();
065        }
066    
067        public int getId()
068        {
069            return id;
070        }
071    
072        public Iterator<Player> players()
073        {
074            return Collections.unmodifiableSet(scores.keySet()).iterator();
075        }
076    
077        public PlayerGameScore getScore(Player p)
078        {
079            return scores.get(p);
080        }
081    }