Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Okay, I have no idea what I\'m doing, could someone please show me where to star

ID: 3926079 • Letter: O

Question

Okay, I have no idea what I'm doing, could someone please show me where to start, help me get the code down something! I'm struggling so bad.

Class Card

It has a suit and a rank.
o Suit should be declared from an enumerate data type that you build which allows

JOKER, CLUBS,DIAMONDS,HEARTS,SPADES
o Rank can be an integer from 0 to 13, Assign Aces the rank of 1.

The default constructor will create a JOKER with a rank of 0

A parameterized constructor that accepts rank and suit for convenience.

o Throw an exception if the input is not correct.

Be sure to have set and get methods. The set methods should be private to prevent

someone from changing the card.

The Card class should provide a method to returns its description in a string object. That

is it will have a ‘toString() method that returns a string object that looks like: Ace of Hearts

Seven of Clubs.

Joker

Be sure to test each method you create. I know it will be difficult to test the private set

methods. Have the parameterized constructor call them.

With the toString() function, the Card object should be easy to print. Test with

cout<<Card.toString()

Remember this should have both a specification file (.h) and an implementation file

(.cpp)

The enum for the suits should be declared outside the class (in the header file). This is to

be sure it is available others needing it.

Main Program

The main or driver program create an array of 52 cards and print them. Randomly pick a card and print it.
makefile

Please include a makefile for compilation. There will be 3 files in it!

Explanation / Answer

#include #include #include #include using namespace std; int suits[4]={1, 2, 3, 4}; int faces[12]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; class Card { public: int face,suit; Card(int face,int suit) { this->face=face; this->suit=suit; } string toString() { string nameSuit; string nameFace; if (suit == 1) nameSuit = "Hearts"; else if(suit == 2) nameSuit = "Diamonds"; else if(suit == 3) nameSuit = "Spades"; else if (suit == 4) nameSuit = "Clubs"; if (face == 1) nameFace = "Ace"; else if(face == 10) nameFace = "Jack"; else if(face == 11) nameFace = "Queen"; else if(face == 12) nameFace = "King"; else { for (int i = 2; i < 10; i++) { nameFace = "" + i; } return nameFace+" of "+nameSuit; } }; class DeckOfCards { private: vector deck; int currentCard,index; public: DeckOfCards() /*create deck*/ { currentCard=1; for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote