• Advertisement
Sign in to follow this  

Need help with functions

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I implement this function New Game() In case 1: #include <iostream> #include <string> #include <stdlib.h> #include <conio.h> using namespace std; int choice=0; void NewGame(); void GameMenu(); bool playingGame=true; bool answer1=true; void NewGame() { cout<<"\t\t _|_|_ cout<<"\t\t _|_|_ cout<<"\t\t | | cout<<"\t\t } void GameMenu() { cout<<"\t\t **************************\n"; cout<<"\t\t * *\n"; cout<<"\t\t * *\n"; cout<<"\t\t * 1. New Game *\n"; cout<<"\t\t * 2. High Score *\n"; cout<<"\t\t * 3. Options *\n"; cout<<"\t\t * 4. Exit *\n"; cout<<"\t\t * *\n"; cout<<"\t\t *Created By C_Programmer!*\n"; cout<<"\t\t **************************\n"; } int main() { while(playingGame) { GameMenu(); cout<<"Choose from the Menu: "; cin>>choice; switch(choice) { case 1: cout<<"Starting New Game\n"; break; case 2: cout<<"High Score Works\n"; break; case 3: cout<<"Options Works\n"; break; case 4: playingGame=false; cout<<"Exiting Works\n"; break; } } system("PAUSE"); return 0; } Thank You!!!!

Share this post


Link to post
Share on other sites
Advertisement
Just call 'NewGame()' in the 'case 1:' expression:

#include <iostream>
#include <string>
#include <stdlib.h>
#include <conio.h>

using namespace std;

int choice=0;

void NewGame();
void GameMenu();
bool playingGame=true;
bool answer1=true;

void NewGame()
{
// I added quotes and 'endl' below
cout<<"\t\t _|_|_ " << endl;
cout<<"\t\t _|_|_ " << endl;
cout<<"\t\t | | " << endl;
cout<<"\t\t " << endl;


}

void GameMenu()
{
cout<<"\t\t **************************\n";
cout<<"\t\t * *\n";
cout<<"\t\t * *\n";
cout<<"\t\t * 1. New Game *\n";
cout<<"\t\t * 2. High Score *\n";
cout<<"\t\t * 3. Options *\n";
cout<<"\t\t * 4. Exit *\n";
cout<<"\t\t * *\n";
cout<<"\t\t *Created By C_Programmer!*\n";
cout<<"\t\t **************************\n";


}
int main()
{
while(playingGame)
{
GameMenu();

cout<<"Choose from the Menu: ";
cin>>choice;

switch(choice)
{
case 1:
cout<<"Starting New Game\n";
// call to 'NewGame()' function
NewGame();
break;
case 2:
cout<<"High Score Works\n";
break;
case 3:
cout<<"Options Works\n";
break;
case 4: playingGame=false;
cout<<"Exiting Works\n";
break;

}

}

system("PAUSE");
return 0;
}




Good luck,
Pat.

Share this post


Link to post
Share on other sites
Make sure you use darookie's updated NewGame function. You had forgotten to put quotes and endl's (or \n);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement