Due Date:
Thursday, February 1
File(s) to be submitted:
Deck.java
Sample Output:
SampleOutput.html
Starter Files:
Summary
Create a class (Deck) to represent a deck of cards.I have provided you with two programs you can run to test your Deck class. One is a testing program, and the other is a game.
In this assignment you are to create a class for a deck of cards. Download the starter files (linked above). Create a new class named Deck in the project. This last file is the only one that you'll be editing for this assignment.
I have provided you with a class Card that represents a single playing card.
Do not modify this class. It performs exactly the way I want it to.It contains several constants and two Lists that will be helpful to you:
Card aceOfClubs = new Card(ACE, CLUBS);creates the ace of clubs. And, of course, you can use variables in the constructor. So if r = 3 and s = DIAMONDS then
Card card = new Card(r, s);creates the 3 of diamonds.
Your first task in this assignment is to create the Deck class. It represents a deck of cards using a List instance variable. The class implements the following methods and constructors:
It's here that the Lists SUITS and RANKS can be useful.The majority of the others can be done in a single line.
Remember to start with stubs for all the methods above. Once you have all the stubs written, compile and run the test program and the card game. The results will look odd, but will start to fill out as you fill in the proper method definitions.
I have provided two driver programs for you. The first one (TestDeck)is a simple testing program. It runs thru some tests of your deck and gives you a simple PASS/FAIL result for each. It's the program you want to start with.
The second driver (Crazy8s) plays a variety of the Crazy Eights card game. It deals out the cards and lets you play with three computer players. The object of the game is to get rid of all your cards by playing them on the centre discard pile. However, you can only play a card that matches the suit or rank of the top card on the pile -- except you may play an 8 at any time.
In this version of the game you do not get to "name" the new suit when you play an eight. Instead the next player must match the suit of the eight that you played (or play an eight of their own).If you can't play, you must draw cards until you can play. If you play a two, the next player must pick up two cards. If you play a jack, the next player misses their turn. Other cards have no effect.