I am currently working on the card game "War" in Greenfoot. I have defined Player1 and Player2 and the score. I was wondering how to add a point to a specific player's score if they win that round.
Help! stuck there...
I did not know there was a scoring system for that game. I always that it was just a win/lose type game. Even the number of cards one has does not really mean so much as how many high cards, particularly aces, one has. At any rate, code was not provided for either player nor for what you have for scoring. We cannot lead you in the right direction or even suggest any way to fix code that is not visible.
public void compareTo(Cards card2)
{
if ( value == card2.getNumValue() )
{
score.updateScore("Player One: " + player1Count, "Player Two: " + player2Count);
}
if ( value > card2.getNumValue() )
{
score.updateScore("Player One: " + player1Count, "Player Two: " + player2Count);
}
if ( value < card2.getNumValue() )
{
score.updateScore("Player One: " + player1Count, "Player Two: " + player2Count);
}
}
Yes, I'm aware that this game doesn't usually work that way but I just did it this way to make things easier for me. I sort of figured out something here, but it says "int cannot be dereferenced" at updatesScore.