Question: I need help writing a program in C + + using File I / O , delimeters, and etc.I need help with the following: Part
I need help writing a program in C using File IO delimeters, and etc.I need help with the following:
Part A
Loading Cards
Add a static LoadCards method to the WarGame class.Declare your method in the WarGame.h file and define the method in the WarGame.cpp file.
It should have a string parameter for the file path.In the method, it should read the cards.csv file and split the data to get the suits and faces.
Use them to create
unique cards and store each card in the cards vector field of the class.
NAME RETURNS PARAMETERS
LoadCards nothing string
Call the LoadCards method from the WarGame constructor.
Part A
Showing Cards
Add a static ShowCards method to the WarGame class.Declare your method in the WarGame.h file and define the method in the WarGame.cpp file.
Loop over the vector and call the Print method on each card.Make sure each card appears on a new line.
NAME RETURNS PARAMETERS
ShowCards nothing none
In case of the menu, call the ShowCards method from mainwhich is in the CardWars.cpp file
Part A
HighScore class
Add a HighScore class with a name field and a score field both with getter
setter methods.
Add a constructor that takes a name and score.
Part A
Player class
Add a Player class with a name field, a score field, a pile field which is a vector of cards, and a won field which is a vector of cards.Add gettersetter methods for the score and name fields.
Add the following methods : HasCards, PushCard, PopCard, and WonCards.
HasCards will return true if there are cards in the pile vector.
PushCard will take a card parameter and add it to the pile vector of cards.
PopCard will remove a card from the pile vector of cards and return the card.
WonCards will take a vector of cards and add it to the won vector of cards and update the score field.
#include "WarGame.h
#include
#include
#include
#include
#include
#include "Input.h
#include "Card.h
std::vector WarGame::cards;
WarGame::WarGamestring cardsFile
LoadCardscardsFile;
void WarGame::LoadCardsconst string& filePath
ifstream filefilePath;
string line;
void WarGame::shuffle
int ndx ndx;
srandunsigned inttimeNULL;
for sizet i ; i ; i
ndx rand;
ndx rand;
Card temp cardsndx;
cardsndxcardsndx;
cardsndx temp;
#pragma once
#include
#include
#include "Card.h
class WarGame
public:
WarGamestd::string cardsFile;
static void LoadCardsconst string& filePath;
static void ShowCards;
private:
static std::vector cards;
static void shuffle;
;
#include "Card.h
#include
#include
#include
#include
#include
#include
void Card::print
std::cout std::setwface;
#if definedWIN definedMSDOS
setmodefilenostdoutOUTEXT;
#endif
ifsuit"Hearts"
std::wcout HEART;
else ifsuit "Diamonds"
std::wcout DIAMOND;
else if suit "Clubs"
std::wcout CLUB;
else if suit "Spades"
std::wcout SPADE;
std::wcout.flush;
#if definedWIN definedMSDOS
setmodefilenostdoutOTEXT;
#endif
int Card::compareCard& otherCard
int pValue getCardValueface;
int cValue getCardValueotherCardGetFace;
if pValue cValue
return ;player wins
else if pValue cValue
return ;npc wins
return ;
int Card::getCardValuestd::string face
int value;
if sizeofface card
value ;
else
char first face;
if first A
value ;
else if first J
value ;
else if first Q
value ;
else if first K
value ;
else
value std::stoiface;
return value;
return intface;
#pragma once
#include
using namespace std;
#if definedWIN definedMSDOS
#define SPADE x
#define CLUB x
#define HEART x
#define DIAMOND x
#else
#define SPADE u
#define CLUB u
#define HEART u
#define DIAMOND u
#endif
enum Suit
Hearts
Diamonds,
Clubs,
Spades
;
enum Face
Ace Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King
;
class Card
public:
Cardstd::string suit, std::string face
suit suit;
face face;
std::string GetSuit const return suit;
void SetSuitstd::string suitsuit suit;
std::string GetFace const return face;
void SetFacestd::string faceface face;
void print;
int compareCard& otherCard;
private:
std::string suit;
std::string
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
