Question: I need help writing a program in C + + using File I / O , delimeters, card.csv and etcthe code ive provided.I need help
I need help writing a program in C using File IO delimeters, card.csv and etcthe code ive provided.I need help with the following:
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.
cards.csv:
Hearts?Diamonds?Clubs?Spades
AJQK
main file
CardWars.cpp
#include
#include "Console.h
#include "Input.h
#include "WarGame.h
#include "Tester.h
int main
Tester cardWarsTest;
Console::ResizeWindow;
int menuSelection ;
std::vector menuOptions Show Cards", Show High Scores", Play Card Wars", Exit" ;
std::string highScoreFile "HighScores.csv;
std::string cardsFile "cards.csv;
WarGame warcardsFile;
do
Console::Clear;
menuSelection Input::GetMenuSelectionmenuOptions;
Console::Clear;
switch menuSelection
case :
After creating the ShowCards method to the WarGame class, call the method here.
break;
case :
After creating the ShowHighScores method to the HighScore class, call the method here passing the highScores vector.
break;
case :
After creating the PlayGame method to the WarGame class, call the method here passing the highScoreFile string and the highScores vector.
break;
default:
break;
Input::PressEnter;
while menuSelection menuOptions.size;
WarGame.h:
#pragma once
#include
#include
#include "Card.h
class WarGame
public:
WarGamestd::string cardsFile;
private:
static std::vector cards;
static void shuffle;
;
WarGame.cpp
#include "WarGame.h
#include
#include
#include
#include
#include
#include "Input.h
#include "Card.h
std::vector WarGame::cards;
void WarGame::shuffle
int ndx ndx;
srandunsigned inttimeNULL;
for sizet i ; i ; i
ndx rand;
ndx rand;
Card temp cardsndx;
cardsndxcardsndx;
cardsndx temp;
Card.h:
#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;
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
