This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gugeek
Gugeek wrote ...

2017/7/24

How do you add to a specific player's score in a game on Greenfoot?

Gugeek Gugeek

2017/7/24

#
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...
danpost danpost

2017/7/24

#
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.
Gugeek Gugeek

2017/7/24

#
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.
danpost danpost

2017/7/24

#
What does your updateScore method look like? or rather, what code do you have for the class that method is in?
You need to login to post a reply.