Sign in to follow this  
C_Programmer0101

Need help with functions

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this