package Cooperative;

/**
 * Author: Max Buegler - max@sarstech.com
 * Date: Oct 14, 2009
 * Time: 10:37:47 PM
 */
public class Coalition {
    private int[] players;
    private double value;
    public Coalition(int[] players, double value) {
        this.players = players;
        this.value = value;
    }
    public int[] getPlayers(){return players;}
    public double getValue(){return value;}
    public boolean contains(int p){
        for (int x=0;x<players.length;x++)
            if (players[x]==p)return true;
        return false;
    }

    public void setValue(double value) {
        this.value = value;
    }

    public boolean equals(Object e){
        if(!(e instanceof Coalition))return false;
        Coalition c=(Coalition)e;
        if (c.getPlayers().length!=players.length)return false;
        for (int x=0;x<c.getPlayers().length;x++)
            if (!contains(c.getPlayers()[x]))return false;
        return true;
    }
    public String toString(){
        String s=players[0]+"";
        for (int x=1;x<players.length;x++){
            s+=" , "+players[x];
        }
        s+=" = "+value;
        return s;
    }
}
