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

can you help me finid it. adn here is program 3 1. Introduction This assignment

ID: 3827333 • Letter: C

Question

can you help me finid it. adn here is program 3

1. Introduction This assignment provides an introduction to programming with classes and with composition, an object-oriented programming technique in which one object contains one or more instances of a different type of object. In this program, you will model a deck of cards. You will also write more member functions in this lab that allow you to read and modify data members, as well as manipulate data in more interesting ways. 2. Deliverables You should submit five files for this assignment: • prog3_main.cpp: Source file containing your main function. • Card.h: Header file containing the Card class definition. • Card.cpp: Source file containing definitions of Card member functions. • DeckOfCards.h: Header file containing the DeckOfCards class definition. • DeckOfCards.cpp: Source file containing definitions of DeckOfCards member functions. Submit all five files by uploading them to your Dropbox folder. Ensure your file names match the names specified above. Do not place these files in a subdirectory—place them directly in your shared folder. Failure to meet this specification will reduce your grade, as described in the program grading guidelin

Introduction The assignment provides an Introduction to working with queue objects. You will revisit the card and deck classes written in Program 3, modifying them (if necessary) to play the classic-and simple-card game of War. This assignment was adapted from an assignment written by Professor Phil Viall at UMass Dartmouth for ECE 161: Foundations of Computer Engineering II. Deliverables You should submit five files for this assignment: prog5_main.cpp: Source file containing your main function. Card5.h/Card5.cpp: Header/source files containing the card class definition and member function definitions. Deck.h/Deck.cpp: Source file containing definitions of Deck member functions. Submit all five files by uploading them to your Dropbox folder. Ensure your file names match the names specified above. Do not place these files in a subdirectory-place them directly in your shared folder. Failure to meet this specification will reduce your grade, as described in the program grading guidelines.

Explanation / Answer

Answer:

1. Card.h

------------------------------

#ifndef CARD_H_
#define CARD_H_

enum card_suit {SPADES=1, HEARTS, DIAMONDS, CLUB};
enum card_face {ACE=1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK=11,QUEEN=12,KING=13};

//Card class
class Card {
public:
   Card();
   Card(card_suit suit, card_face face);
   card_face getFace();
   void setFace(card_face face);
   card_suit getSuit();
   void setSuit(card_suit suit);
private:
   card_suit suit;
   card_face face;
};

#endif /* CARD_H_ */

--------------------------------

2. Card.cpp

----------------------------------

#include "Card.h"

//Implementation of methods of card class

//Constructor
Card::Card(card_suit suit, card_face face)
{
   this->suit=suit;
   this->face=face;
}

Card::Card()
{

}

//Getters and Setters
card_face Card::getFace(){
   return face;
}

void Card::setFace(card_face face) {
   this->face = face;
}

card_suit Card::getSuit(){
   return suit;
}

void Card::setSuit(card_suit suit) {
   this->suit = suit;
}

----------------------------------------

3. DeckOfCards.h

--------------------------------------

#ifndef DECKOFCARDS_H_
#define DECKOFCARDS_H_

#include "Card.h"

#define SUITS_IN_DECK 4
#define CARDS_IN_SUIT 13

using namespace std;

//DackOfCards class
class DeckOfCards {
public:
   DeckOfCards();
   void shuffle();
   Card drawCard();
   Card* getCardDeck();
   Card getDrawnCard();
   void setDrawnCard(int drawnCard);
   int getCardsInDeck() const;
   void setCardsInDeck(int cardsInDeck);

private:
   Card card_deck[SUITS_IN_DECK*CARDS_IN_SUIT];
   int drawn_card;
   int cards_in_deck;
};

#endif /* DECKOFCARDS_H_ */

----------------------------------------------

4. DeckOfCards.cpp

---------------------------------------------

#include <algorithm>
#include <cstdlib>
#include "DeckOfCards.h"

using namespace std;

//Constructor
DeckOfCards::DeckOfCards()
{
   // TODO Auto-generated constructor stub
   int k=0;
   for(int i=1;i<=SUITS_IN_DECK;i++)
   {
       for(int j=1;j<=CARDS_IN_SUIT;j++)
       {
           card_suit suit=(card_suit)i;
           card_face face=(card_face)j;
           Card card(suit,face);
           card_deck[k]=card;
           k++;
       }
   }
   cards_in_deck=k;
   shuffle();
   drawn_card=-1;
}

Card* DeckOfCards::getCardDeck(){
   return card_deck;
}

Card DeckOfCards::getDrawnCard(){
   return card_deck[drawn_card];
}

void DeckOfCards::setDrawnCard(int drawnCard) {
   drawn_card = drawnCard;
}

Card DeckOfCards::drawCard()
{
   int val=rand()%cards_in_deck;
   cards_in_deck--;
   return card_deck[val];
}

void DeckOfCards::shuffle()
{
   random_shuffle(card_deck,card_deck+(SUITS_IN_DECK*CARDS_IN_SUIT));
}

int DeckOfCards::getCardsInDeck() const {
   return cards_in_deck;
}

void DeckOfCards::setCardsInDeck(int cardsInDeck) {
   cards_in_deck = cardsInDeck;
}

--------------------------------------

Output:

---------------------------------------

Cards in deck:52
Drawn Card:
Suit:4,Face:4
Remaining cards in deck:51

--------------------------

Note: For this question, access to the code of classes mentioned in problem statement is required. But that is not provided. So, I have developed the above classes for your reference.

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