BrandonA Brown wrote:I am just now getting ready to learn the GUI part of it but before I get into all of that, I wanted to write a simple card game.
Well that's a really good thing to do right there.
Java GUIs - in fact, GUIs in general - are fiddly, verbose and distracting; so
anything you can do to delay writing them (IMO) is
good.
(You may, perhaps, have gathered from the advice above that I'm not a big fan of them )
Remember: A GUI is concerned with two things,
and two things ONLY:
Displaying content.Getting response from a user.It cannot play a game for you. For that, you need a class that knows
the rules and logic of the game.
And
you should try as hard as you possibly can to keep the two things
separate.
And on that subject, I have one basic criticism of your
Deck class: It does things that I don't associate with a deck of
cards; specifically:
Start_Game() and (arguably)
Deal_PlayerCards(). And that's because you're already thinking about what you're going to DO with it.
It may well work, but it'll be a "one trick pony"; and if you decide to write a program to play another game like Poker, or Canasta (or Snap), you'll have to rewrite your
Deck class from scratch - even though you'll probably find that you copy a lot of code between them because they all use the same
type of deck (4 suits, 52 (or 54) cards, A, K, Q, J, 10... etc).
So you need to separate what a deck IS from the game it's used in - and to do that you need to think about what a
Deck actually is.
And basically, it boils down to a bunch of "cards", each of which has a suit and a name, which suggests that you might also want a
Card class...
You'll certainly want to be able to shuffle it, but dealing is likely to depend entirely on the game it's used in.
Now I don't want to inundate you with design here, or re-write your class; but do you see how you might want to break up some of the stuff that's currently in your
Deck and put it in your
War class? Because
that's the class that knows how to USE the
Deck. Without the game, a
Deck is just a pile of cards.
HIH
Winston