Card program , need help thanks.
I am in need for some help with this assignment. I have started it, but did not get far. Heres my assignment. Any help is appreciated.
Your assignment is to create a CardDrawer class that would simulate the drawing of cards for a card game.
Although most card games require a standard 52 card deck, some games require a smaller deck. An example would be the card game Euchre. It only uses the cards 9,10,Jack,Queen,King, Ace of all 4 suites.
Also some games may have multiple decks, meaning it is possible to draw the same card more than once.
Therefore, you will need 4 constructors for this class.
- a default constructor that has typical 52 card deck where each card can only be drawn once.
- a second constructor that has a 52 card deck however it will allow the same card to be redrawn more than once.
- a third constructor that allows a client class to pass the smallest and largest cards that are possible to be draw as parameters. You can use numbers for face cards. (ie jack = 11, queen = 12, etc)
For example since Eucre requires the use of the cards 9,10,jack,queen,king, and ace.
The client class would pass 9 and 14 (notice in this case the ace would have the value of 14)
You will need to think about how to make the Ace work in the other examples as well.\
This constructor will only allow a card to be drawn once.
- a fourth constructor that is the same as #3 but where a card can be drawn more than once.
You will then create 2 drawCard methods.
- The first method will accept no parameters and draw a single card.
- The second drawCard method will accept an integer parameter that will draw the number cards based on the passed parameter. Ie suppose the following method call was made. game.drawCard(5); This would draw 5 cards. These cards would be put into an array.
In both of these methods you will also have to account for which constructor was used to create the class. For example, if the first constructor was used (the default were a typical 52 card deck is used and a card can only be drawn once) you will need to make sure all 52 cards can be drawn, but you also have to create an array or ArrayList that will be checked each time to be sure a card is not drawn more than once. (Hint: create a variable that determines if a card can be drawn more than once. If it can your method would ignore the check. If it canít be drawn more than once, your method will then run though the array and check to see if that card has already been drawn. You would set this variable in the constructor.
Because methods can only return a single value, you canít return both the suite and card value. The way you will get around this is to return a Card object. This means a Card class must be created also. Therefore each time a card is drawn, a card object is created. The Card object will contain both the suite and card value. This single card object can then be passed back or entered into the array of cards that will be passed back.
The Card class will actually be quite simple at this point. The constructor will accept two parameters for the suite and card value. It will also contain two methods that allow a client class to get the suite and card value returned.