|
I need help with this code I can't seem to get it right please help.
#include<iostream>
#include<string>
using namespace std;
enum gameName{odd, even};
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);
int main ()
{
int selection;
int play1, play2;
int sum;
int gameCount;
int winCount1, winCount2;
int num[5];
int counter;
int gamewinner;
char response;
int selection1, selection2;
int gamePlay1;
int gamePlay2;
gameCount = 0;
winCount1 = 0;
winCount2 = 0;
displayRules();
cout << "Enter Y|y to play the game: ";
cin >> response;
cout << endl;
while ( response == 'Y' || response == 'y')
{
cout << "Player1 enter your choice: ";
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++;
}
cout << "Enter Y | y to play the game: ";
cin >> response;
cout << endl;
}
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);
cout << "Player1 selected: ";
convertEnum(play1);
cout << " and Player2 selected: ";
convertEnum(play2);
cout << " ";
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>
|
|
|
|
|
so, what is the problem ? does it compile ? does it give wrong answers ? having problem with the logic ?
for example :
if (gamewinner == 1)
winCount1++;
so what happens with player 2 ? doesn't she ever win ?
This signature was proudly tested on animals.
|
|
|
|
|
The answer to the question is that it dose not complier. I have 3 errors like
'gameResult' : cannot convert parameter 1 from 'int' to 'gameName'.
|
|
|
|
|
You should do like
(gameName)yourIntVariable
But should always use the right ENUM value.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I'm not sure I understand what you are saying. I'm confused!
|
|
|
|
|
You are trying to pass an int to argument that takes your ENUM, i.e gamename.
Ok Just post the exact line where you get the error message.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
here is the lines
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;
}
|
|
|
|
|
No I wanted the exact line. I mean when you click on the error, it takes you to the line right? that one. Anyway tell me one thing,
gameName winningOdject(gameName play1, gameName play2, odd, even)
{
}
What's the type of "odd" & "even" here?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
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};
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);
int main ()
{
int selection;
int play1, play2;
int sum;
int gameCount;
int winCount1, winCount2;
int num[5];
int counter;
int gamewinner;
char response;
int selection1, selection2;
int gamePlay1;
int gamePlay2;
gameCount = 0;
winCount1 = 0;
winCount2 = 0;
displayRules();
cout << "Enter Y|y to play the game: ";
cin >> response;
while ( response == 'Y' || response == 'y')
{
cout << "Player1 enter your choice: ";
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++;
}
cout << "Enter Y | y to play the game: ";
cin >> response;
cout << endl;
}
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);
cout << "Player1 selected: ";
convertEnum(play1);
cout << " and Player2 selected: ";
convertEnum(play2);
cout << " ";
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>
|
|
|
|
|
How to skin scrollbar of all controls in Application?
(TreeCtrl, ListCtrl, ComboBox)
|
|
|
|
|
Do you maybe need this[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
thanks for ur link.
But that is not the solution for my probs.
I want to make my own custom skinning of all Windows controls whcih ever suppports scrollBar.
Is there any Hooks available?
Or How to subclass the CScrollBar and integrate the same with TreeControl, ListControl & ComboBox.
Hope u understood my problem.
Thanks in advance.
|
|
|
|
|
Maybe try this[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks for ur link!!!!
I cannot able to download the files,.
can u help me??
|
|
|
|
|
Why can't you download it?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
In my application, I store an array of TCHAR[MAX_PATH] strings into an vector as indicated by the code snippet below.
#include <vector>
typedef std::vector<std::basic_string<TCHAR>> StringVector;
BOOL CMyApp::AddStringToVector()
{
StringVector vect;
vect.push_back(_T("One"));
vect.push_back(_T("two"));
vect.push_back(_T("three"));
TCHAR szResult[MAX_PATH]={0};
_tcscpy(szResult, vect[1]);
}
I am able to add all the string. But accessing the stored string from the vector is the problem.
_tcscpy(szResult, vect[1]); gives an compilation error
Error 11 error C2664: 'wcscpy' : cannot convert parameter 2 from 'std::basic_string<_Elem,_Traits,_Ax>' to 'const wchar_t *'
I think this error is caused because the TCHAR that is stored in the vector as std::basic_string<_Elem,_Traits,_Ax> and that the compiler is not able to convert it to an TCHAR[MAX_PATH].
How do I go about accessing the TCHAR elements in the vector?
Please help.
|
|
|
|
|
Got the solution.
I should be using to access the TCHAR stored in the vector as given below.
_tcscpy(szResult, vect[1].c_str());
|
|
|
|
|
I have an excel file which is connecting with some other network application and continously updating the excel file. now i want to see that data on my gui . what is the required api for it
Trioum
|
|
|
|
|
Which message gets processed by application when user presses "windows+d" or clicks "show desktop" icon in quick launch so application minimizes?
|
|
|
|
|
Well, you get a WM_SIZE[^] message when your window gets minimized but i doubt there is a way to distinguish between the event of "show desktop" and any other cause of minimizing (like the user clicking the minimize button). Why do you have to know that?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I have application, in custome menu I have option "minimize", by clicking on it application goes to sys tray, now menu option would be "restore" ...but that two case(mentioned in Q) option remains "minimize" as application is minimized all ready? it shud be "restore"
|
|
|
|
|
Well, WM_SIZE[^] with SIZE_MINIMIZED in lParam should tell you your app got minimized and i guess SIZE_RESTORED should tell you if it got restored or SIZE_MAXIMIZED if it got maximized, but if i were you i would rather query the window'S state using GetWindowPlacement[^] and set my menu item accordingly every time the menu is shown, i think it is easier to handle than tracking some flag thoroughout the application...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Application does not get WM_SIZE message in both case mentioned in Q.
|
|
|
|
|
Hmm, you are right, one would think it would get a WM_SIZE, same with WM_WINDOWPOSCHANGED...sorry about that...i see what else i find, if i figure out anything i will get back to you...how about GetWindowPlacement mentioned in my other[^] post?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Still I'm confused, application minimizes (in both cases) but message Q does not process any message how this is possible?
|
|
|
|