Question: Help with error in code. Line 5 5 too few arguments in function call and 'Input::GetInteger' function does not take 1 arguments #include WarGame.h

Help with error in code. Line 55 too few arguments in function call and 'Input::GetInteger' function does not take 1 arguments
#include "WarGame.h"
#include
#include
#include
#include
#include
#include "Input.h"
std::vector WarGame::_cards;
WarGame::WarGame(std::string cardsFile)
{
LoadCards(cardsFile);
}
void WarGame::LoadCards(std::string filePath)
{
std::ifstream file(filePath);
if (!file.is_open())
{
std::cerr << "Failed to open the file." << std::endl;
return;
}
std::string line, suits, faces;
std::getline(file, suits); // Read the first line for suits
std::getline(file, faces); // Read the second line for faces
std::stringstream ssSuits(suits);
std::stringstream ssFaces(faces);
std::vector suitList, faceList;
std::string suit, face;
while (std::getline(ssSuits, suit, '?'))
{
suitList.push_back(suit);
}
while (std::getline(ssFaces, face, '?'))
{
faceList.push_back(face);
}
for (const auto& s : suitList)
{
for (const auto& f : faceList)
{
_cards.emplace_back(s, f);
}
}
file.close();
}
void WarGame::ShowCards()
{
for (const auto& card : _cards)
{
card.Print();
std::cout << std::endl;
}
}
void WarGame::shuffle()
{
int ndx1, ndx2;
srand((unsigned int)time(NULL));
for (size_t i =0; i <52; i++)
{
ndx1= rand()%52;
ndx2= rand()%52;
Card temp =_cards[ndx1];
_cards[ndx1]=_cards[ndx2];
_cards[ndx2]= temp;
}
}
void WarGame::PlayGame(const std::string& playerName, std::vector& highScores, const std::string& highScoreFile)
{
shuffle();
Player npc("NPC");
Player player(playerName);
for (size_t i =0; i <_cards.size(); ++i){
if (i %2==0)
player.PushCard(_cards[i]);
else
npc.PushCard(_cards[i]);
}
std::vector unclaimedPile;
while (player.HasCards() && npc.HasCards()){
Card playerCard = player.PopCard();
Card npcCard = npc.PopCard();
std::cout << player.GetName()<<"'s card: ";
playerCard.Print();
std::cout <<" vs NPC's card: ";
npcCard.Print();
std::cout << std::endl;
unclaimedPile.push_back(playerCard);
unclaimedPile.push_back(npcCard);
int compResult = playerCard.Compare(npcCard);
if (compResult ==1){
player.WonCards(unclaimedPile);
unclaimedPile.clear();
std::cout << player.GetName()<<" wins this round!" << std::endl;
}
else if (compResult ==-1){
npc.WonCards(unclaimedPile);
unclaimedPile.clear();
std::cout <<"NPC wins this round!" << std::endl;
}
else {
std::cout << "It's a tie!" << std::endl;
}
}
std::cout <<"
Final Scores:
";
std::cout << player.GetName()<<": "<< player.GetScore()<< std::endl;
std::cout <<"NPC: "<< npc.GetScore()<< std::endl;
if (npc.GetScore()> player.GetScore()){
std::cout <<"NPC won the game!" << std::endl;
}
else if (npc.GetScore()< player.GetScore()){
std::cout << player.GetName()<<" won the game!" << std::endl;
if (player.GetScore()> highScores.back().GetScore()){
HighScore newHighScore(player.GetName(), player.GetScore());
auto it = std::lower_bound(highScores.begin(), highScores.end(), newHighScore,
[](const HighScore& lhs, const HighScore& rhs){
return lhs.GetScore()> rhs.GetScore();
});
highScores.insert(it, newHighScore);
highScores.pop_back();
HighScore::SaveHighScores(highScoreFile, highScores);
HighScore::ShowHighScores(highScores);
}
}
else {
std::cout << "The game is a tie!" << std::endl;
}
int playAgain = Input::GetInteger("Do you want to play again? (1 for yes, 2 for no): ");
if (playAgain ==1){
PlayGame(playerName, highScores, highScoreFile);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!