Hey guys how is everyone today? I just had a couple questions and wondering if anyone could help.
I been trying to write a Xcode 4 cocoa app that is a guessing game. I was able to complete the game in the console, but now that I am trying to link it to a UI I'm finding it not so easy.
This is the basic Idea, i know its off. I had it working at one point but every time i hit the button it generated a new random number and i can't figure out how to do it outside the button, and how to add 5 tries before calling game over.
I been trying to write a Xcode 4 cocoa app that is a guessing game. I was able to complete the game in the console, but now that I am trying to link it to a UI I'm finding it not so easy.
This is the basic Idea, i know its off. I had it working at one point but every time i hit the button it generated a new random number and i can't figure out how to do it outside the button, and how to add 5 tries before calling game over.
Code:
@implementation LoopingAppDelegate
-(void)setStuff:(id)sender{
NSInteger g = [input];
NSInteger y;
NSInteger x = rand() % 100;
}
- (IBAction)run:(id)sender
{
[y setIntValue:[x intValue]];
if([g] intValue] == x){
[results setStringValue:@"YOU ARE CORRECT SIR!!!"];
return;}
else if(guess.intValue < y.intValue){
[results setStringValue:@"Higher \nGuess again!"];}
else if(guess.intValue > y.intValue){
[results setStringValue:@"Lower \nGuess again!"];}
else {
[results setStringValue:@"What the **** did you type??!?!"];
}
}