Click here to Skip to main content
15,905,322 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Displaying Chinese character. Pin
gothic_coder8-Mar-09 23:56
gothic_coder8-Mar-09 23:56 
GeneralRe: Displaying Chinese character. Pin
«_Superman_»8-Mar-09 23:59
professional«_Superman_»8-Mar-09 23:59 
GeneralRe: Displaying Chinese character. Pin
gothic_coder9-Mar-09 0:39
gothic_coder9-Mar-09 0:39 
General[Message Deleted] Pin
gothic_coder9-Mar-09 0:41
gothic_coder9-Mar-09 0:41 
GeneralRe: Displaying Chinese character. Pin
«_Superman_»9-Mar-09 0:47
professional«_Superman_»9-Mar-09 0:47 
GeneralRe: Displaying Chinese character. Pin
gothic_coder9-Mar-09 1:04
gothic_coder9-Mar-09 1:04 
GeneralRe: Displaying Chinese character. Pin
gothic_coder9-Mar-09 6:23
gothic_coder9-Mar-09 6:23 
Generalhelp plaese Pin
doit397-Mar-09 2:15
doit397-Mar-09 2:15 
I need help with this code I can't seem to get it right please help.
// This is a game of odd and even.

#include<iostream>
#include<string>
using namespace std;
enum gameName{odd, even};

  // function prototypes
void displayRules();
gameName retrievePlay(int selection);
bool valdSelection(char selection);
void convertEnum(gameName odject);
gameName winningOdject(gameName play1, gameName play2);
void gameResult(gameName play1,gameName  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++;
		}  //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;
}
  gameName winningOdject(gameName play1, gameName play2,  odd, even)
{
	if ((play1 == odd)&& (play2 ==even)||
		(play2 == odd) && (play1 == even));
		return odd;
	if (( play1 == even) && (play2 == even) ||
		  ( play2 == even) && (play1 == even));
		  return even;
}

void gameResult(gameName play1, gameName play2 ,int& winner)
{
	gameName 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 = 1;
	 if  (play2 == winnerOdject)
		 winner = 2;
	 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;
}</pre> 

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

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.