Question: I am having trouble with an error I am getting from this code. I am unsure how to fix this. This week's focus is namespace,

I am having trouble with an error I am getting from this code. I am unsure how to fix this. This week's focus is namespace, so should I add namespace to the Chapter7-Textadventure.cpp? Here is assignment and each file:

As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. Currently, there is a test program that calls a player's class. The program asks the player for a name and then gives options on what happens next. The only option available is to quit. Add an additional option and supporting code in the player header that will allow the player to input a preferred console type. After the player inputs a preferred console type, be sure to redisplay it.

Chapter7-Textadventure

// Chapter7-TextAdventure.cpp : Defines the entry point for the console application. //

#include "stdafx.h" #include "Player.h" #include "GameLoop.h" #include

using namespace std;

int main() { Game game; game.RunGame("pause");

return 0; }

GameLoop.cpp

#include "GameLoop.h" #include

using namespace std;

void Game::WelcomePlayer() { cout

string name; cin >> name; m_player.SetName(name);

cout

void Game::GivePlayerOptions() const { cout

void Game::GetPlayerInput(string& playerInput) const { cin >> playerInput; }

PlayerOptions Game::EvaluateInput(string& playerInput) const { PlayerOptions chosenOption = PlayerOptions::None;

if (playerInput.compare("1") == 0) { cout

else if (playerInput.compare("3")) { cout

else { cout

return chosenOption; }

void Game::RunGame() { WelcomePlayer();

bool shouldEnd = false; while (shouldEnd == false) { GivePlayerOptions();

string playerInput; GetPlayerInput(playerInput);

shouldEnd = EvaluateInput(playerInput) == PlayerOptions::Quit; } }

GameLoop.h

#pragma once

#include "Player.h" #include "PlayerOptions.h"

class Game { private: Player m_player;

void WelcomePlayer(); void GivePlayerOptions() const; void GetPlayerInput(std::string& playerInput) const; PlayerOptions EvaluateInput(std::string& playerInput) const; public:

void RunGame(); };

Player.h

#pragma once

#include

class Player { private: std::string m_name;

public: Player() { }

void SetName(const std::string& name) { m_name = name; }

const std::string& GetName() const { return m_name; } };

PlayerOptions.h

#pragma once

enum class PlayerOptions { Quit, Pause, Settings, Options, None };

stdafx.h

// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently //

#pragma once

#include "targetver.h"

#include #include

// TODO: reference additional headers your program requires here

targetver.h

#pragma once

// Including SDKDDKVer.h defines the highest available Windows platform.

// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.

#include

Here is the error I am getting:

I am having trouble with an error I am getting from this

Error List + x Entire Solution O Messages Build + IntelliSense - Code Line * 2 Errors A Warnings Description Project too many Chapter 7-TextAdventure arguments in function call "Game:RunGame': Chapter 7-TextAdventure function does not take 1 arguments Suppression State File Chapter 7-TextAdventure.cpp 14 * C2660 chapter 7-textadventure.cpp

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 Databases Questions!