/**
 * Java Class for Six Nimmt cards.  Cards are numbered from 1 to 104, and
 * have a predetermined number of BullHeads on them.  BullHeads are negative
 * points for a player if they are in their scoring pile at the end of the game.
 * If a card is a multiple of 5 and 11, it has 7 BullHeads, if it is only a multiple
 * of 11, it has 5 BullHeads, if only a multiple of 5, it has 3 BullHeads, otherwise
 * it has 1 BullHead.
 */
public class NimmtCard {

    private int number;
    private int player;

    public NimmtCard(int number) {
	this.number = number;
	this.player = -1;
    }

    /** Returns the number for the card */
    public int getNumber() {
	return number;
    }

    /** Returns the number of BullHeads on the card. */
    public int getBullHeads() {
	if (number % 5 != 0 && number % 11 != 0) {
	    return 1;
	} else if (number % 5 != 0) {
	    return 5;
	} else if (number % 11 != 0) {
	    return 3;
	} else {
	    return 7;
	}
    }

    /** Sets the player of this card */ 
    public void setPlayer(int player) {
	this.player = player;
    }

    /** 
     * Returns the player in the game who played this card, helpful
     * for determining who gets what cards from the stacks
     */ 
    public int getPlayer() {
	return player;
    }

    /** Gives a string representation of a Six Nimmt Card */
    public String toString() {
	String s = "" + number + ":";
	for (int i = 0; i < getBullHeads(); i++) {
	    s += "*";
	}
	return s;
    }

    /** Returns true if two NimmtCards have the same number */
    public boolean equals(Object o) {
	if (o instanceof NimmtCard) {
	    NimmtCard other = (NimmtCard)o;
	    if (this.number == other.number) {
		return true;
	    }
	}
	return false;
    }

    /** For unit testing, demonstrates how to make a deck of Nimmt Cards. */
    public static void main(String[] args) {
        java.util.ArrayList<NimmtCard> deck = new java.util.ArrayList<NimmtCard>();
	for (int i = 0; i < 104; i++) {
	    deck.add(new NimmtCard(i + 1));
	}
	for (NimmtCard c : deck) {
	    System.out.println(c);
	}
    }
}
