problem creating a deck of cards in java

Posted 22 November 2011 - 10:30 AM

im trying to create a deck of cards in java, but there must be a Card class with an array of suit and an array of value and a deck class which is able to shuffle and deal the cards etc. and im unsure if im creating the array properly. this is the code ive got so far. would anyone be able to show me where im going wrong

Replies To: problem creating a deck of cards in java

Re: problem creating a deck of cards in java

Posted 22 November 2011 - 10:56 AM

Java variable names should being lower case. The arrays you have defined do nothing at the moment - what do you plan to use them for?
Consider using enum for the various ranked entities. There are examples of this for a Card class in the Oracle Java enum tutorial

Re: problem creating a deck of cards in java

Posted 22 November 2011 - 02:07 PM

At the very least if you do use String[] to represent the suits and values (the names should be plural as well to be descriptive), they should be globals or at least instance fields, rather than local variables that will keep being recreated each time toString() is called.