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

You have two homework assignments: a) finish implementing the Setsuit function s

ID: 3819761 • Letter: Y

Question

You have two homework assignments:

a) finish implementing the Setsuit function so that it only allows suits we defined (DIAMOND, CLUB, HEART, and SPADE)

b) finish the skeleton for our Deck class, attached. You should add any member variables and member functions that you think we will need in order to be able to play a card game with our Deck of Cards.

#ifndef DECK_H
#define DECK_H

// Add the member variables and member functions needed to create and work with our Deck object
// Hint: our deck will be a std::array of Card objects
class Deck
{
public:
Deck();

protected:

private:
};

#endif // DECK_H

#include <iostream>
#include "Card.h"

using namespace std;

main.cpp

int main()
{

Card john; // create a variable named john of type card 4D
Card mary; // create a variable named mary of type card4D

std::cout << "john is a: " ;
john.print();
std::cout<<std::endl;
mary.Setrank( ACE );
mary.Setsuit((Suit)50);
mary.print();
return 0;
}

card.h

#ifndef CARD_H
#define CARD_H

//DEFINE our rank enumerated type
enum Rank{TWO=2, THREE, FOUR, FIVE, SIX, SEVEN, EIGTH, NINE, TEN , JACK, QUEEN, KING ,ACE};
// define our suit enumerated type
enum Suit{DIAMOND, CLUB, HEART, SPADE};

class Card
{
public:
Card(); // constructor

//extra functions we need
void print(); // pretty print for our card


// since our member variables are private we need helper functions
Rank Getrank() { return m_rank; }
void Setrank(Rank val) ; // set function prototype
Suit Getsuit() { return m_suit; }
void Setsuit(Suit val) ; // set function prototype

protected:

private:
Rank m_rank; // member variable stores card's rank
Suit m_suit; // member variable stores card's suit
};

#endif // CARD_H

Explanation / Answer

#ifndef DECK_H
#define DECK_H

// Add the member variables and member functions needed to create and work with our Deck object
// Hint: our deck will be a std::array of Card objects
class Deck
{
public:
Deck();

protected:

private:
};

#endif // DECK_H

#include <iostream>
#include "Card.h"

using namespace std;

main.cpp

int main()
{

Card john; // create a variable named john of type card 4D
Card mary; // create a variable named mary of type card4D

std::cout << "john is a: " ;
john.print();
std::cout<<std::endl;
mary.Setrank( ACE );
mary.Setsuit((Suit)50);
mary.print();
return 0;
}

card.h

#ifndef CARD_H
#define CARD_H

//DEFINE our rank enumerated type
enum Rank{TWO=2, THREE, FOUR, FIVE, SIX, SEVEN, EIGTH, NINE, TEN , JACK, QUEEN, KING ,ACE};
// define our suit enumerated type
enum Suit{DIAMOND, CLUB, HEART, SPADE};

class Card
{
public:
Card(); // constructor

//extra functions we need
void print(); // pretty print for our card


// since our member variables are private we need helper functions
Rank Getrank() { return m_rank; }
void Setrank(Rank val) ; // set function prototype
Suit Getsuit() { return m_suit; }
void Setsuit(Suit val) ; // set function prototype

protected:

private:
Rank m_rank; // member variable stores card's rank
Suit m_suit; // member variable stores card's suit
};

#endif // CARD_H

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