Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok I think this will help you in the long run. I looked at your code for about two seconds and saw it has some serious structural problems. Here is where you should start at:</p> <pre><code>public enum Suit { CLUBS, SPADES, HEARTS, DIAMONDS } </code></pre> <hr> <pre><code>public enum Value { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE } </code></pre> <hr> <pre><code>public class Card { private Value value; private Suit suit; public Card(Suit theSuit, Value theValue) { suit = theSuit; value = theValue; } public Value getValue() { return value; } public Suit getSuit() { return suit; } } </code></pre> <p>Now once we have that base established we can also say that a hand and a deck are very similar because they are both a stack of cards so we should build a base for them:</p> <pre><code>public class CardStack { public ArrayList&lt;Card&gt; cards; public CardStack() { cards = new ArrayList&lt;Card&gt;(); } public Card draw() { if(cards.size() &gt; 0) { Card card = cards.objectAt(cards.size() - 1); cards.remove(card); return card; } return null; } public void addCard(Card card) { cards.add(card); } } </code></pre> <p>Now the rest is up to you, Deck and Hand should both extend CardStack. Sorry for the extremely long answer but this will help you in the long run. If the structure is wrong the program will never run properly. You should obviously have a Player class and it should have an instance of Hand and your Game class or whatever should have an instance of deck. The deck should have a shuffle and reset method, Hand really only needs like a clear meathod. I hope this helped you out! Good Luck!</p> <hr> <p>UPDATE</p> <p>Here is more on enums if you don't know what they are:</p> <ul> <li><a href="http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html</a></li> </ul> <p>Here is some general OOP information:</p> <ul> <li><a href="http://docs.oracle.com/javase/tutorial/java/concepts/" rel="nofollow">http://docs.oracle.com/javase/tutorial/java/concepts/</a></li> </ul> <p>If you read both of those your code will dramatically improve. If you need more help I can post more code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload