| FtK shadow (1) | |||||
|
Alright I have been working on this game for like a week or 2 now, but I am having some trouble towards the end. I need it for c++ work, but I have gotten so far I am sure someone can give me a little help with some bits. Heres the code I have gotten so far:
I am missing this part I just realized and dont know how I can take it out and make it a function.
I also realized it doesn't take a dollar away when you lose. another part I am also missing is
Anyone know of a good way to add these. I have been trying and keep doing something wrong. If someone could help me out here I would be so thankful :) | |||||
|
|
|||||
| Zaita (2301) | |||||
4.
3.
That should be more than sufficient code to help you on your way. | |||||
|
|
|||||
| HeatMan (65) | |
|
Not use the || ! It will accept any letter! Use this: if (!(variable != 'y' && variable != 'Y'))thanks to Jsmith. | |
|
|
|
| Zaita (2301) | |||||
My code will only accept Y or y, all other values are to be considered a negative response. If the answer is Y or y then it'll return true, thus continuing the while-loop and re-calling the game function. Do notice I am doing a string comparison, not a char comparison, and I am using getLine() not >>. Happy to be corrected, but you should test other peoples code before you say it won't work. Code:
| |||||
|
Last edited on
|
|||||
| HeatMan (65) | |
| Uh... :P Sorry then ^^' | |
|
|
|
| jsmith (5804) | |
|
HeatMan, I appreciate you citing references, though I answered your question about DeMorgan's rule without concern of the context of the question. Although they are identical, I would never condone using if( !( !expr && !expr ) )in place of if( expr || expr )as I find the former unilaterally more confusing than the latter. More than likely you were experiencing operator precedence problems that was leading you to conclude that the former was necessary, whereas in fact it isn't. | |
|
|
|