Question: I have a C++ assignment that I need to write a class that calls upon the loop.cpp file, but I am very confused on how

I have a C++ assignment that I need to write a class that calls upon the loop.cpp file, but I am very confused on how to write the class, can someone help me please? : Currently, there is a test program that calls a players 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.

//Main TextAdventure.cpp

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

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

int _tmain(int argc, _TCHAR* argv[]) { Game game; game.RunGame();

return 0; }

//GameLoop.cpp

#include "GameLoop.h" #include

using namespace std;

void Game::WelcomePlayer() { cout << "Welcome to Text Adventure!" << endl << endl; cout << "What is your name?" << endl << endl;

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

cout << endl << "Hello " << m_player.GetName() << endl; }

void Game::GivePlayerOptions() const { cout << "What would you like to do? (Enter a corresponding number)" << endl << endl; cout << "1: Quit" << endl << endl; }

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

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

if (playerInput.compare("1") == 0) { cout << "You have chosen to Quit!" << endl << endl; chosenOption = PlayerOptions::Quit; } else { cout << "I do not recognise that option, try again!" << endl << endl; }

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; } };

/*Error w/codes

Severity Code Description Project File Line Suppression State Error (active) E0282 the global scope has no "tanhf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 636 Error (active) E1696 cannot open source file "float.h" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cfloat 7 Error (active) E0282 the global scope has no "acosf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 629 Error (active) E0282 the global scope has no "asinf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 629 Error (active) E0282 the global scope has no "atanf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 630 Error (active) E0282 the global scope has no "atan2f" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 630 Error (active) E0282 the global scope has no "ceilf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 630 Error (active) E0282 the global scope has no "cosf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 631 Error (active) E0282 the global scope has no "coshf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 631 Error (active) E0282 the global scope has no "expf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 631 Error (active) E0282 the global scope has no "fabsf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 632 Error (active) E0282 the global scope has no "floorf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 632 Error (active) E0282 the global scope has no "fmodf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 632 Error (active) E0282 the global scope has no "frexpf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 633 Error (active) E0282 the global scope has no "ldexpf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 633 Error (active) E0282 the global scope has no "logf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 633 Error (active) E0282 the global scope has no "log10f" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 634 Error (active) E0282 the global scope has no "modff" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 634 Error (active) E0282 the global scope has no "powf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 634 Error (active) E0282 the global scope has no "sinf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 635 Error (active) E0282 the global scope has no "sinhf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 635 Error (active) E0282 the global scope has no "sqrtf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 635 Error (active) E0282 the global scope has no "tanf" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cmath 636 Error (active) E1696 cannot open source file "errno.h" Chapter7-TextAdventure c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\cerrno 7 */

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!