class State { public int[] cards = new int[6]; public int lastPlay; public int currentNum; public Player loser; public State() { for(int i =0; i < cards.length; i++) cards[i] = 4; lastPlay =-1; loser = null; currentNum = 0; } /* public int[] viewCards() { int result = new int[cards.length]; for (int i = 0; i < cards.length; i++) result[i] = cards[i]; return result; }*//* public int lastPlayed() { return lastPlay; }*/ public void setLoser( Player p ) { loser = p; } public boolean gameFinished() { return currentNum > 31; } public String toString() { String result = "Game at "+currentNum+">>"; for (int i = 0; i < 6; i++) result = result + " "+ (i+1)+":"+cards[i]; return result; } public void playCard( int card ) { lastPlay = card; currentNum = currentNum + card+1; cards[card]--; } public State revertedCopy() { State s = new State(); for(int i = 0; i < 6; i++) s.cards[i] = cards[i]; s.lastPlay = lastPlay; s.loser = loser; s.currentNum = currentNum-lastPlay; s.cards[lastPlay]++; return s; } public State makeCopy() { State s = new State(); for(int i = 0; i < 6; i++) s.cards[i] = cards[i]; s.lastPlay = lastPlay; s.loser = loser; s.currentNum = currentNum; return s; } }