Question: Project 1 COSC 1030 Basic instructions (if completed, you will earn a C) Create a class for a single playing card. Here is the UML:
Project 1 COSC 1030 Basic instructions (if completed, you will earn a C)
Create a class for a single playing card. Here is the UML:
Card
Private data members are your design
+Card()
+Card(rank:int, suit:TBD)
+getSuit(): int (or char)
+getRank(): int
+setCard(rank:int, suit(TBD)):void
+setRandom():void
+compare(c:Card): int
+compare(c1:Card, c2:Card): int
+toString():String
Features:
(Watch lecture video for more specific instructions)
Data members can be of your design. The public member methods should act like the rank and suit of a real card, but how you keep track is your choice.
The other members are as you would expect, with the following: setRandom will set the cards value to a random rank and suit toString() will return a string with the card represented any way that is reasonable. (rank, suit)
Create a driver program that will thoroughly test your card class.
Then, use your card class to create a deck class. The constructor should initialize the deck (52 cards) to all the cards in a deck. Here is a possible start for the UML:
Deck
Deck[] Card
+Deck()
+deal():Card
+numLeft():int
+shuffle():void
+toString()
The constructor should create the array of 52 unique cards.
The other methods act as you would expect
You may deviate from the UML as you see fit, as long as the public members behave as expected Write a driver program that thoroughly tests your deck class
Intermediate project (You will earn an B)
Blackjack Card Game
You are to create a blackjack hand class. This class will contain a hand (up to 11 cards). UML as follows:
BlackjackHand
- Cards[] hand
-numCards int
+BlackjackHand()
+getScore() int
+addCard(Card c) void
+resetHand() void
+toString() String
Write a driver to play Blackjack with one player.
Advanced project (You will earn an A)
Modify your BlackjackHand so that you can keep track of players name, money on hand, money bet, and adjust after a hand depending on if the player won, lost, or tied.
Create a game with up to 5 players and a dealer. For each round, do the following:
Reset all hands Place bets (up to amount of money on hand) Deal two Cards to everyone Go from player to player, asking if they wish to hit or stay. Any total 22 or more they automatically lose and are done. Once all players are through, deal cards to the dealer as follows:
o 16 or less the dealer must take a Card, 17 or more the dealer must stay
Reconcile all bets If a players pot is empty, they are out of the game
Hints, tips, and things to think about:
We are creating a virtual deck of Cards. The only requirement is that it appears to be a real deck: that means that it should act like one. There is no requirement that it actually is coded just like one. As an example, you will probably have an array of Cards that is your deck. To deal these cards, you probably start with the first card (at index 0), and keep track of a local variable that indicates the index of the next card to be dealt. That is how a real deck works. However, we could pick a random card out of the deck and return it, instead of the top card. We would then need a way to determine which have been dealt and which are left. Not how an actual deck would work, but still it appears to work as a deck would really work. Shuffle could actually rearrange the cards randomly, or leave them all where they are at and just indicate that none have been dealt yet. Here is a thought, and use it if you wish: Your deck may not need any actual cards at all. You just need to return an object of class Card when deal is called, but you could create an object and return it when asked, rather than keep an array of Cards waiting around to be dealt. There is an old saying in programming: if it seems that there must be an easier way to do this, there probably is. So, if you find that your code is becoming way to voluminous and complicated, step back and design a new plan.
Last thoughts
This project has absolutely no right or wrong way to do this. I intend for you to show me that you understand Object Oriented Programming and can apply the principles to a complicated project. Be creative, and have fun.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
