Scott Dunning wrote:
I'm also having trouble creating the method to deal out five cards...
Scott Dunning wrote:
...that also tells how many cards are left in the deck...
Scott Dunning wrote:
...and I believe I need a toString method but I honestly do not know how to go about that.
Joel Christophel wrote:
Scott Dunning wrote:
I'm also having trouble creating the method to deal out five cards...
First, think of the act of dealing real cards. From where in the deck are the cards drawn, and which indexes of your deckOfCards array do they correspond to?
Scott Dunning wrote:
...that also tells how many cards are left in the deck...
Whenever a card is dealt, you could indicate that the deck array index no longer points to a Card object. Then, you could count the cards in the deck by checking how many indexes of the array actually point to a Card.
Scott Dunning wrote:
...and I believe I need a toString method but I honestly do not know how to go about that.
It seems as if your Card class already has a toString method, which would appear to be useful in the reporting of dealt cards.
Scott Dunning wrote:
I just need to figure out how and where to tell how many cards are left in the deck. Any ideas?
Scott Dunning wrote:
Also, how bad does my code look? I got a little bit of advice but I'd imagine it's still a mess. Any tips on cleaning it up?
You mean constants follow THAT_CONVENTION. A final variable might not be a constant because it might point to a mutable reference type, so that is inconstant.Joel Christophel wrote: . . . final variables should follow THIS_CONVENTION. . . .
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|