Click here to Skip to main content
15,919,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: help plaese Pin
Maximilien7-Mar-09 2:43
Maximilien7-Mar-09 2:43 
AnswerRe: help plaese Pin
doit397-Mar-09 3:11
doit397-Mar-09 3:11 
GeneralRe: help plaese Pin
Eytukan7-Mar-09 4:15
Eytukan7-Mar-09 4:15 
GeneralRe: help plaese Pin
doit397-Mar-09 5:05
doit397-Mar-09 5:05 
GeneralRe: help plaese Pin
Eytukan7-Mar-09 6:07
Eytukan7-Mar-09 6:07 
GeneralRe: help plaese Pin
doit397-Mar-09 11:46
doit397-Mar-09 11:46 
GeneralRe: help plaese Pin
Eytukan7-Mar-09 18:15
Eytukan7-Mar-09 18:15 
GeneralRe: help plaese Pin
doit398-Mar-09 17:40
doit398-Mar-09 17:40 
I change allot of the code so I will post it again still need help I have to turn it in at midnight tonight.
<#include<iostream>>

using namespace std;
enum game{odd, even};

  // function prototypes
void displayRules();
game retrievePlay(int selection);
bool valdSelection(char selection);
 convertEnum(game odject);
game winningOdject(game play1, game play2);
void gameResult(game play1, game play2,  int& winner);
void displayResults(int gCount, int wCount1, int wCount2);

 // step 1
int main ()
{
	int selection;
	int play1, play2;
	int sum;
	int gameCount;                          // variable to store the number of games played.
	int winCount1, winCount2;              // variables to store the number of games won by players 1 and 2.
    int num[5];                          //array to store the five numbers
	int  counter;   
	int gamewinner;                        
	char response;                         // variable to get the users response to play the game.
	int selection1, selection2;
   int gamePlay1;
    int gamePlay2;                  //player's1 and player's2 selection.
    
	//Initialize variables; step 2.

	gameCount = 0;
	winCount1 = 0;
	winCount2 = 0;

	displayRules();                        //step 3

	cout << "Enter Y|y to play the game: ";  // step 4 
	cin >> response;
	//cout << endl;

	while ( response == 'Y' || response == 'y')
	{
		cout << "Player1 enter your choice: ";  //step 6
		cin >> selection1;
		cout << endl;

		cout << "player2 enter your choice: ";
		cin >> selection2;
		cout << endl;

		if ( valdSelection(selection1) && valdSelection(selection2))
		{
			play1 = retrievePlay(selection1);
			play2 = retrievePlay(selection2);
			gameCount++;
			gameResult(play1, play2, gamewinner);

			if (gamewinner == 1)
				winCount1++;
			else (gamewinner ==2);
				winCount2++;
		}  //end if.

		cout << "Enter Y | y to play the game: ";
		cin >> response;
		cout << endl;
	} // end while

	displayResults(gameCount, winCount1, winCount2);
    
	for ( counter = 0; counter < 5; counter++)
		cin >> num[counter];
	sum = sum + num[counter];
	cout << endl;

	return 0;
}

void displayRules();
{
	cout << "Hi and welcome to the game Odds and Evens." << endl;
	cout << "This is a game for one or two players." << endl;
	cout << "The rules of the game are has follows:" << endl;
	cout << "1. the players choise either Odds or Evens." << endl;
	cout << "2. The players choise a number between 1 and 5." << endl;
	     << "3. After player choise there number. " <<endl;
		 << "The sum of the numbers either equal a odd number of an even number." << endl;
	cout << "The winner is the player that has the right choise." << endl;
}
game winningOdject(game play1, game play2)
{

	if ((play1 == odd)&& (play2 ==even)||
		(play2 == odd) && (play1 == even));
		return odd;
	if (( play1 == even) && (play2 == even) ||
		  ( play2 == even) && (play1 == even));
		  return even;
}

  void gameResult( game play1,  game play2, int& winner)
{
	 
	game winnerOdject;

	winnerOdject = winningOdject(play1, play2);     
	// outputs each players choise
	cout << "Player1 selected: ";
         convertEnum(play1);
		 cout << " and Player2 selected: ";
		 convertEnum(play2);
		 cout << " ";

		 // Decide the winner

     if( play1 == winnerOdject)
		 winner = play1;
	 if  (play2 == winnerOdject)
	 winner = play2;
	 cout << "Player " << winner << " wins this game." <<endl;
}
void displayResults(int gCount, int wCount1, int wCount2)
{
	cout << "The total number of games: " << gCount << endl;
	cout << "The number of games won by player1: " << wCount1 << endl;
	cout << "The number of games won by player2: " << wCount2 << endl;
}:confused:/pre> 

QuestionHow to skin scrollbar of all controls in Application? Pin
siva4557-Mar-09 1:55
siva4557-Mar-09 1:55 
AnswerRe: How to skin scrollbar of all controls in Application? Pin
Code-o-mat7-Mar-09 2:29
Code-o-mat7-Mar-09 2:29 
GeneralRe: How to skin scrollbar of all controls in Application? Pin
siva4559-Mar-09 1:09
siva4559-Mar-09 1:09 
GeneralRe: How to skin scrollbar of all controls in Application? Pin
Code-o-mat9-Mar-09 1:24
Code-o-mat9-Mar-09 1:24 
GeneralRe: How to skin scrollbar of all controls in Application? Pin
toolsrnd9-Mar-09 2:29
toolsrnd9-Mar-09 2:29 
GeneralRe: How to skin scrollbar of all controls in Application? Pin
Code-o-mat9-Mar-09 2:34
Code-o-mat9-Mar-09 2:34 
QuestionAccessing TCHAR[] array from an vector. Pin
Comp_Users7-Mar-09 0:06
Comp_Users7-Mar-09 0:06 
AnswerRe: Accessing TCHAR[] array from an vector. Pin
Comp_Users7-Mar-09 0:21
Comp_Users7-Mar-09 0:21 
Questionexcel file problem Pin
trioum6-Mar-09 23:47
trioum6-Mar-09 23:47 
Questionwindows+D? Urgent please. Pin
sam_psycho6-Mar-09 23:32
sam_psycho6-Mar-09 23:32 
AnswerRe: windows+D? Urgent please. Pin
Code-o-mat7-Mar-09 0:03
Code-o-mat7-Mar-09 0:03 
GeneralRe: windows+D? Urgent please. Pin
sam_psycho7-Mar-09 0:14
sam_psycho7-Mar-09 0:14 
GeneralRe: windows+D? Urgent please. Pin
Code-o-mat7-Mar-09 0:23
Code-o-mat7-Mar-09 0:23 
GeneralRe: windows+D? Urgent please. Pin
sam_psycho7-Mar-09 0:17
sam_psycho7-Mar-09 0:17 
GeneralRe: windows+D? Urgent please. Pin
Code-o-mat7-Mar-09 0:35
Code-o-mat7-Mar-09 0:35 
GeneralRe: windows+D? Urgent please. Pin
sam_psycho8-Mar-09 19:49
sam_psycho8-Mar-09 19:49 
GeneralRe: windows+D? Urgent please. Pin
Code-o-mat8-Mar-09 22:35
Code-o-mat8-Mar-09 22:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.