Java-halfway-challenge
The week 9 challenge, on the nology course, was to model a card game using the Java language. The challenge was broken down into small parts.
STAGE 1
Using classes, ArrayLists and methods, create a deck of Cards. You should use the following classes:
CardGame
• Contains an ArrayList
• Has a name which is also defined in the constructor.
• Has a getDeck method that lists out the cards in the deck.
Card
• Has a String suit. Use the unicode characters of heart, club, diamond and spade
• Has a String symbol (2,3,4,5,6,7,8,9,10,J,Q,K,A)
• Has an int value (2,3,4,5,6,7,8,9,10,11,12,13,14)
• Has a toString method that describes the class
STAGE 2
Add methods for the CardGame class that allow for the following:
• Card dealCard() - takes the card from the top of the deck and returns it
• ArrayList
• ArrayList
• ArrayList
STAGE 3
Create class for Snap that extends CardGame. This class should use the methods defined above, as well as some new ones, to enable the user to play the game snap according to the following rules: By pressing enter in the command line, the user takes their turn. Each turn, a new card is dealt from the deck. The game continues until two cards in a row have the same symbol, at which point the “player” wins and the game ends.
STAGE 4a
Create a Player class and enable the snap game to be two player, with the users taking it in turns to go. If the snap occurs on the users turn, they win.
STAGE 4b
Add a timer so that when there is a snap opportunity, the player has 2 seconds to submit the word “snap” in order to win. If they don’t type it in time, they lose.