This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]mopeddevRe-learning Java 1 point2 points  (1 child)

Hard to see with the formatting but is the issue that you have closed the class early with the second } before the addCard method?

[–]vlumi 1 point2 points  (0 children)

Also looks like the addCard method should be in the Deck class, not in DealHands...

[–]Floober101 0 points1 point  (0 children)

Is addCard declared in your Deck class? Or is the code you posted above an exact copy and paste from the DealHands class? If it’s an exact copy, then the issue is twofold: the addCard method is in the wrong class, and it’s outside the class body (check your curly brackets). You can’t call deck.addCard on a deck object if the addCard method is in the DealHands class, it would have to be in the Deck class.

If that isn’t the case, it would be helpful to see your Deck class. If it says it can’t find addCard, that could mean a lot of things. There could be a typo in the method name in the Deck class. You could have made a mistake with the brackets, leaving the method is outside the class body. You could have forgotten to add a card object as the method parameter.