Question: I need help coding a program in C + + using File I / O , delimeters, accessing the data from cards.csv file specifically, open,
I need help coding a program in C using File IO delimeters, accessing the data from cards.csv file specifically, open, reading, closing files, and etc with the code ive provided.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 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;
void print;
int compareCard& otherCard;
private:
std::string suit;
std::string face;
int getCardValuestd::string face;
;
Card.cpp:
#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
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
