With what I know so far I am trying to just make a small program. A game called War with 10 cards (integers). The goal is to mix 10 cards into an array. Then I pull a card and then the computer. I am putting the cards into it's own class. I am compiling as I go to trouble shoot. The goal is to apply what I am learning.
Main:
Interface:
Implementation:
When I compile I get an error with this line, and another but this one first.
It says it 'Expected and identifier or ( before [ token' But I already identified this as in INT in the interface?
Main:
Code:
#import <Foundation/Foundation.h>
#import "cards.h"
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog(@"***** Welcome to WAR! ******");
NSLog(@"Mixing the deck");
cards * gameCards = [[cards alloc]init];
[gameCards mixTenCards];
[pool drain];
return 0;
}
Code:
#import <Cocoa/Cocoa.h>
#include <stdlib.h>
@interface cards : NSObject {
int cards[10]; //Card Array
}
-(void) mixTenCards;
-(int) cards;
@end
Code:
#import "cards.h"
@implementation cards
-(void) mixTenCards {
for (int i = 0; i <= 9; i++){
cards[i] = arc4random() % 51 + 1;
}
}
-(int) cards{
return cards;
}
@end
When I compile I get an error with this line, and another but this one first.
Code:
cards[i] = arc4random() % 51 + 1;