Results 1 to 6 of 6
  1. #1
    bbjake is offline Member
    Join Date
    Sep 2014
    Posts
    3
    Rep Power
    0

    Default Unshuffled Deck of Cards

    Hello, I am trying to make a program that will make a deck of 52 cards, but not shuffle it. I can't get rid of the errors in the code that I have so far.

    Java Code:
    public class Deck {
    
        private Card[] deck;
        private int cardsUsed;
        
        public Deck() {
           
        	deck = new Card[52];
        	int cardCt = 0;
        	for ( int suit = 0; suit <= 3; suit++ ) {
        		for ( int value = 1; value <= 13; value++ ) {
        			deck[cardCt] = new Card(value,suit);
        			cardCt++;
        		}
        	}
        	cardsUsed = 0;
        }
    }
    I am getting red squiggly lines on lines:
    #3 under "Card"
    #8 under "deck" and "Card"
    #12 under "deck" and "Card"

  2. #2
    unsensible is offline Member
    Join Date
    Apr 2014
    Posts
    14
    Rep Power
    0

    Default Re: Unshuffled Deck of Cards

    Where is your Card class? If you did not make a Card class, you cannot use it as a datatype. If you did make a Card class, do not forget to import it.

    Also, if you are using eclipse you should be able to hover your mouse over red squiggly lines and it will show you why it is throwing the error.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Unshuffled Deck of Cards

    Perhaps your IDE can't find the Card class. Doesn't it give you any other helpful information like when you hover
    your mouse over the statements?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    bbjake is offline Member
    Join Date
    Sep 2014
    Posts
    3
    Rep Power
    0

    Default Re: Unshuffled Deck of Cards

    Quote Originally Posted by unsensible View Post
    Where is your Card class? If you did not make a Card class, you cannot use it as a datatype. If you did make a Card class, do not forget to import it.

    Also, if you are using eclipse you should be able to hover your mouse over red squiggly lines and it will show you why it is throwing the error.
    WOW, that was an easy fix I just forgot to import the Card class.
    Thanks for the response.

  5. #5
    unsensible is offline Member
    Join Date
    Apr 2014
    Posts
    14
    Rep Power
    0

    Default Re: Unshuffled Deck of Cards

    No problem. By the way, I attached a picture to show you what happens when you hover your mouse over something that needs imported. If you select the first option it'll do it for you. Additionally, Ctrl+shift+O imports everything in your program that is needed to fix errors.

    Unshuffled Deck of Cards-rnhu.png

  6. #6
    bbjake is offline Member
    Join Date
    Sep 2014
    Posts
    3
    Rep Power
    0

    Default Re: Unshuffled Deck of Cards

    Quote Originally Posted by unsensible View Post
    No problem. By the way, I attached a picture to show you what happens when you hover your mouse over something that needs imported. If you select the first option it'll do it for you. Additionally, Ctrl+shift+O imports everything in your program that is needed to fix errors.

    Click image for larger version. 

Name:	RnHu.png 
Views:	13 
Size:	13.0 KB 
ID:	6614
    Thanks for the tips :)

Similar Threads

  1. Help with deck of cards and dealing five cards...
    By sjud9227 in forum New To Java
    Replies: 6
    Last Post: 08-07-2014, 04:12 PM
  2. Deck of Cards Program
    By Hector in forum New To Java
    Replies: 6
    Last Post: 03-12-2014, 07:37 PM
  3. Help with creating a deck of cards
    By Carouselification in forum New To Java
    Replies: 5
    Last Post: 03-06-2011, 05:45 AM
  4. Deck of cards problem
    By VelvetMirror in forum New To Java
    Replies: 2
    Last Post: 02-16-2011, 09:02 PM
  5. Deck of Cards
    By khunmato in forum New To Java
    Replies: 13
    Last Post: 09-06-2009, 06:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •