Exemple #1
0
int main (void)
{
	int menu = 0;

	/* initializes srand () */
	init ();

	do {
		/* prints title and menu on screen */
		printMainScreen ();

		/* requires user to choose a menu */
		menu = chooseMenuItem ();
		
		switch (menu)
		{
			case START_GAME:
				startNewGame ();    /* starts a new game */
				break;

			case GAME_RULES:
				printGameRules ();  /* prints the game rules */
				break;

			case EXIT_GAME:
				printGoodbye ();    /* prints a goodbye message */
				break;
		}

	} while (menu != EXIT_GAME);

	return 0;
}
Exemple #2
0
int main(void){
	double balance = 0, wager = 0;
	int choice = 0;

	printGameRules();
	balance = getBankBalance();
	
	//Display game menu and allow user to continually choose options until they quit
	while(choice != 4){
		displayGameMenu();
		choice = getChoice();
		switch (choice){
			case 1: 
				printf("Current bank balance: $%.2lf\n", balance);
				break;
			case 2: 
				balance = addMoney(balance);
				printf("You now have $%.2lf in the bank\n", balance);
				break;
			case 3:
				balance = playRound(balance);
				break;
			case 4:
				break;
			default:
				printf("\nMenu choice is invalid, Please choose a number between 1 and 4\n"); //Validates menu choice
				break;
		}

	}


	return 0;
}
int main (void)
{	
	int isPlay = FALSE;		/* status indicator if player wants to play again */
	char option = '\0';		/* option chosen from the menu */


	/* Shows intro screen and initializes srand() */
	setup ();

	do
	{
		/* Prints menu on the screen */
		option = printMenu ();

		switch (option)
		{
			case START_NEW_GAME:
				/* Plays a new game */
				play ();
				isPlay = TRUE;
				break;

			case HOW_TO_PLAY:
				/* Prints to the screen the rules of the game */
				printGameRules ();
				isPlay = TRUE;
				break;

			case EXIT_GAME:
				/* Exits out from the game */
				isPlay = FALSE;
				break;
		}

	} while (isPlay);

	return 0;
}