Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How can I get my card game running?

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How can I get my card game running?

    Firstly, I would like to point out that this assignment is already past due so even if you were to program it for me, it would do me no good other than me learning it. I have been trying to figure out how to program this but I have had no luck. I simply want someone to guide me on how to do this and not so much tell me how to do it but help me so I can figure it out. Any advice would be helpful.

    Here is what I was given

    CSCI 3326, Lab3: Create a deck of playing cards

    Topics: Objects, private versus public attributes and methods, ArrayList/LinkedList containers, object composition

    Create a ‘Card’ class (in a file named Card.java) to get part 1 of the Driver.java test program working. Next, create a ‘DeckOfCards’ class (in a file named DeckOfCards.java) and get the remaining steps of the program working. The Driver.java provides test code along with the proper output of the test run.


     
    import java.util.*;
     
    public class Driver
    {
    	public static void main(String [] args)
    	{
     
    		//Step 1:  Test Card class
    		Card joker, fiveHeart, eightClub, aceDiamond, kingSpade;
     
    		joker = new Card();
    		fiveHeart = new Card(5,"heart");
    		eightClub = new Card(8, "club");
    		aceDiamond = new Card(1, "diamond");
    		kingSpade = new Card(13, "spade");
     
     
    		System.out.println("Here are the cards: " + joker + ", " + fiveHeart + ", " +
    							eightClub + ", " + aceDiamond + ", " + kingSpade);
     
    		System.out.println("Testing 'getNum' method: " + eightClub.getNumber());
     
    		System.out.println("Testing 'getSuit' method: " + aceDiamond.getSuit());
     
     
    		//Step 2:  test the deck: make a constructor to create the
    		//standard deck of 52 cards
    		DeckOfCards deck;
    		deck = new DeckOfCards();
     
    		System.out.println(deck);
     
    		//Step 3: shuffle deck and deal a hand..
    		//Note:  dealing a card should remove and return the top card from the deck.
    		deck.shuffle();
     
    		for(int i=0; i<5; i++)
    			System.out.println( deck.dealTopCard() );
     
    		System.out.println("");
     
     
    		//Step 4: try a special deck:
    		ArrayList<String> monsters = new ArrayList<String>();
    		monsters.add("orc");
    		monsters.add("goblin");
    		monsters.add("owlbear");
    		monsters.add("snake");
    		monsters.add("shinyskinvampire");
     
    		DeckOfCards fantasyDeck = new DeckOfCards(10, 12, monsters);
     
    		fantasyDeck.shuffle();
    		System.out.println(fantasyDeck);
     
    //Below is a sample output for the above test program.
     
    /*
    Here are the cards: 0 of jokers, 5 of hearts, 8 of clubs, ace of diamonds, king
    of spades
    Testing 'getNum' method: 8
    Testing 'getSuit' method: diamond
    ace of hearts
    ace of spades
    ace of diamonds
    ace of clubs
    2 of hearts
    2 of spades
    2 of diamonds
    2 of clubs
    3 of hearts
    3 of spades
    3 of diamonds
    3 of clubs
    4 of hearts
    4 of spades
    4 of diamonds
    4 of clubs
    5 of hearts
    5 of spades
    5 of diamonds
    5 of clubs
    6 of hearts
    6 of spades
    6 of diamonds
    6 of clubs
    7 of hearts
    7 of spades
    7 of diamonds
    7 of clubs
    8 of hearts
    8 of spades
    8 of diamonds
    8 of clubs
    9 of hearts
    9 of spades
    9 of diamonds
    9 of clubs
    10 of hearts
    10 of spades
    10 of diamonds
    10 of clubs
    jack of hearts
    jack of spades
    jack of diamonds
    jack of clubs
    queen of hearts
    queen of spades
    queen of diamonds
    queen of clubs
    king of hearts
    king of spades
    king of diamonds
    king of clubs
     
    2 of clubs
    7 of hearts
    8 of diamonds
    ace of hearts
    5 of spades
     
    jack of snakes
    queen of orcs
    10 of shinyskinvampires
    queen of goblins
    queen of snakes
    10 of orcs
    queen of owlbears
    10 of goblins
    10 of snakes
    jack of shinyskinvampires
    jack of goblins
    jack of orcs
    jack of owlbears
    queen of shinyskinvampires
    10 of owlbears
     
    */
     
     
    	}
     
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How can I get my card game running?

    Where exactly are you stuck? What exactly are you confused about?

    Does this code compile? Does it run?

    By the way, I'm moving this from the tutorial forum to the help forum.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Need some assistance with my card game
    By haydenholligan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 14th, 2012, 11:25 AM
  2. Hi Lo card game
    By ryanc33 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 13th, 2012, 07:01 PM
  3. Help with Card Game
    By JSeol14 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 21st, 2012, 10:46 PM
  4. A Card Game
    By Paytheprice in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 25th, 2012, 07:30 AM
  5. Card Game help....
    By macFs89H in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 2nd, 2011, 07:55 AM