package poker;
import java.util.*;
import org.apache.log4j.BasicConfigurator;
public class Player {

public Player (String _name) {
	this.name = _name;}

public ArrayList<Card> getCardsHeld() {return CardsHeld;}
public void getCardFromDealer (Card _card) {CardsHeld.add(_card);}

public boolean Equals (Player other) {
	//TODO: code
	return true;
}

public String toString() {
	
	String _cardsHeld = ""; 
	BasicConfigurator.configure();
	//TODO: DEBUG grammatical error i.e. comma separating each card and "." for the last card, the last rule is not working as expected.
	for (int i = 0; i < CardsHeld.size(); i++) 		{_cardsHeld += CardsHeld.get(i).toString() + " ";}
	
	return (name + " holds the following cards: " + _cardsHeld) ;
}

public int hashCode() {
	/* TODO: FIX/BUG.  Player.hashCode() returning the same hashCode() for different instances.
	 * */
	
	int _hash = 7;
	
	int _cpCount = this.name.codePointCount(0, name.length());
	int _codePointV = 0;
	while (_cpCount < this.name.length()) {
		_codePointV += this.name.codePointAt(_cpCount);
		_cpCount++;
	}
	
	_hash = _hash * 31 + _codePointV;  
	return _hash; 
}
private ArrayList<Card> CardsHeld = new ArrayList<Card>();

public String getName () {return name; }
public Double getBalanceForBetting () {return balanceForBetting;}
public Double getAmountOnTable () {return amountOnTable;}
public void getACard(Card aCard) {
	/*TODO: gets a card from the dealer and returns true if there are no problems (e.g. duplicate card)

	 		Which card has been distributed by the Dealer?

	 		Does the Dealer need to be created as an object?
	 		Maybe, because the dealer holds the deck of cards that the other players do not hold.
	 		To code interfacing strategy between Card and Player.
	 		*/
	this.CardsHeld.add(aCard);
}
private String name;
private Double balanceForBetting;
private Double amountOnTable;
}
