I'm at my wit's end, for the life of me why doesn't this work?
I'm working on a game, and there is a card object. Each card has a string for example an Ace has an "A", a two has a "2", and so on. The card has a method called getStr() which returns the string.
When the world deals the player a card, it calls a method player.assignCard(card) which passes the card information to the player.
The assign card method looks like this:
Card playercard;
String cardname = "";
public void assignCard(card) {
playercard = card; // the player has a variable called playercard
cardname += card.getStr();
}
So the information from the card is passed to the playercard. That works. What I can't understand is why cardname comes out as null. It doesn't make sense! The getStr method merely returns the card's string, that's all it does, and it works in the world when I run the program and inspect the card object itself. Why does it return as null in this method? I don't get it! It should be "A" or "2" or whatever, but it keeps coming up as null!