statistics/src/main/java/cz/xelfi/quoridor/statistics/EloEntry.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 14 Sep 2010 08:56:13 +0200
changeset 264 d60370059c3c
parent 178 4b78d4f028b3
permissions -rw-r--r--
Changing headers to GPLv3
     1 /*
     2  * Quoridor server and related libraries
     3  * Copyright (C) 2009-2010 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, either version 3 of the License.
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program. Look for COPYING file in the top folder.
    16  * If not, see http://www.gnu.org/licenses/.
    17  */
    18 package cz.xelfi.quoridor.statistics;
    19 
    20 import javax.xml.bind.annotation.XmlAttribute;
    21 import java.util.Comparator;
    22 /**
    23  *
    24  * @author Martin Rexa
    25  */
    26 public class EloEntry {
    27     String player;
    28     double elo;
    29     int games;
    30 
    31     public static final Comparator<EloEntry> BEST_FIRST = new BestFirst();
    32 
    33     EloEntry(){
    34         super();
    35     }
    36 
    37     EloEntry(String player, double elo, int games){
    38         super();
    39         this.player = player;
    40         this.elo = elo;
    41         this.games = games;
    42     }
    43 
    44     @XmlAttribute
    45     public String getPlayer(){
    46         return player;
    47     }
    48 
    49     @XmlAttribute
    50     public Double getElo(){
    51         return elo;
    52     }
    53 
    54     @XmlAttribute
    55     public Integer getGames(){
    56         return games;
    57     }
    58 
    59     public String toString(){
    60         return "Player: " + player + ", ELO: " + elo + ", Games: " + games;
    61     }
    62 
    63     private static final class BestFirst implements Comparator<EloEntry> {
    64         public int compare(EloEntry e1, EloEntry e2) {
    65             if(e1.elo > e2.elo)
    66                 return -1;
    67             else if(e1.elo < e2.elo)
    68                 return 1;
    69             else return e1.player.compareTo(e2.player);
    70         }
    71     }
    72 
    73 }