Question
I need help with this C++ console code error. I have been working on these errors for a week now. I have posted this code
I need help with this C++ console code error. I have been working on these errors for a week now. I have posted this code 3 times now in here and would appreciate a solution to these errors it continues to throw. I have left the errors in the comments after I try to use the suggested "answered code" after it debugs, but no one ever offers to answer the error comment question:: **This is the instructions given to fill in the blanks of this assignment: 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.
>>CPP Files<<
//Main TextAdventure.cpp // Chapter7-TextAdventure.cpp : Defines the entry point for the console application. #include "Player.h" #include "GameLoop.h" #include
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; } }
>>stdafx.cpp<<
// stdafx.cpp : source file that includes just the standard includes // Chapter7_TextAdventure.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H // and not in this file
>>Header Files<<
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
PlayerOptions.H
#pragma once
//Class enum class PlayerOptions { //Enumerator Quit, None };
stdafx.h
#pragma once
#include "targetver.h" #include
targetver.h
#include
>>This is the debug error I continue to get.<< It states :
Unable to start program 'C:\###\###\###\Chapter7_TextAdventure.exe'. The system cannot find the file specified. This is the debug errors: Severity Code Description Project File Line Suppression State Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? Chapter7_TextAdventure c:\####l\chapter7_textadventure\chapter7_textadventure\gameloop.cpp 49 Error C1010 unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? Chapter7_TextAdventure c:\####\chapter7_textadventure\chapter7_textadventure\chapter7_textadventure.cpp 14
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started