Question: How to break this to 5 files which is main.cpp , Deck.h , Deck.cpp , Card.cpp , Card.h Please break it and also do the
How to break this to files which is main.cpp Deck.h Deck.cpp Card.cpp Card.h
Please break it and also do the output if it work.
Main.cpp
#include
#include "Deck.h
#include "Card.h
int main
Deck deck;
std::string player player;
Create a new deck
std::cout "Enter player name: ;
std::cin player;
std::cout "Enter player name: ;
std::cin player;
Print unshuffled deck
std::cout "Unshuffled deck:" std::endl;
deck.print;
Shuffle the deck
deck.shuffle;
Print shuffled deck
std::cout "Shuffled deck:" std::endl;
deck.print;
Play rounds cards, per round
int playerWins playerWins ties ;
for int i ; i ; i
Card card deck.deal;
Card card deck.deal;
std::cout "Round i :
player Card: ;
cardprint;
std::cout player Card: ;
cardprint;
std::cout std::endl;
int result cardcomparecard;
if result
std::cout player wins this round!" std::endl;
playerWins;
else if result
std::cout player wins this round!" std::endl;
playerWins;
else
std::cout "It's a tie!" std::endl;
ties;
Print final statistics
std::cout
Final Statistics:
;
std::cout player wins: playerWins std::endl;
std::cout player wins: playerWins std::endl;
std::cout "Ties: ties std::endl;
return ;
Card.h
#ifndef CARDH
#define CARDH
class Card
private:
char rank;
char suit;
public:
Constructor to create card with given suit and rank
Cardchar r char s : rankr suits
Default constructor
Card : rank suit
Function to print card details
void print const
std::cout rank suit ;
Function to compare two cards' ranks
int compareconst Card& other const
if rank other.rank
return ; Tie
else if rank other.rank
return ; Win
else
return ; Lose
;
#endif
Deck.h
#ifndef DECKH
#define DECKH
#include "Card.h
#include
#include
#include
class Deck
private:
Card cards; Array to hold cards
int currentCard;
public:
Constructor to create a deck of cards
Deck
char suitsHDSC;
char ranksTJQKA;
currentCard ;
Populate deck with cards
for int i ; i ; i
for int j ; j ; j
cardscurrentCard Cardranksj suitsi;
currentCard ; Reset to start dealing from the top of the deck
Shuffle the deck
void shuffle
srandtime; Seed random number generator
for int i ; i ; i
int r i rand i;
Card temp cardsi;
cardsi cardsr;
cardsr temp;
Deal a card from the deck
Card deal
return cardscurrentCard;
Print all cards in the deck
void print const
for int i ; i ; i
cardsiprint;
if i
std::cout std::endl;
;
Please break the card and deck to two file which are h and cpp
And also test the program, thanks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
