Ok donc je suis tout nouveau à l'objectif C et pour m'entraîner un peu j'ai fait un petit petit programme. Les programmes supposent comprendre combien de jours êtes-vous. J'ai cette erreur que je ne peux pas comprendre. Heres le code:Objectif C Aide (débutant)
Age.h
#import <Foundation/Foundation.h>
@interface Age : NSObject {
int age;
int age365;
int lyear;
}
-(void) howOld;
@end
Age.m
#import "Age.h"
@implementation Age
-(void) howOld{
NSLog(@"How old are you currently?\n");
scanf("age");
NSLog(@"You entered %i", age);
}
@end
Month.h
#import "Age.h"
@interface Month : Age{
int month;
}
-(void) whatMonth;
@end
Month.m
#import "Month.h"
@implementation Month
-(void) whatMonth{
NSLog(@"What month is it? (Number)\n");
scanf("month");
NSLog(@"you entered %i", month);
}
@end
Day.h
#import "Month.h"
@interface Day : Month{
int day;
}
-(void) whatDay;
-(void) printAge;
@end
Day.m
#import "Day.h"
@implementation Day
-(void) whatDay{
NSLog(@"What day is it? (Number)");
scanf("day");
NSLog(@"You entered %i", day);
day = month*30+day+age365;
}
-(void) printAge{
age365 = age * 365;
lyear = age/4;
age = lyear + age365;
NSLog(@"You are %i days old", day);
}
@end
main.m
#import <Foundation/Foundation.h>
#import "Age.h"
#import "Month.h"
#import "Day.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
Age *a = [[Age alloc]init];
[a howOld];
Month *m = [[Month alloc]init];
[m whatMonth];
Day *d = [[Day alloc]init];
[d whatDay];
[d printAge];
}
return 0;
}
Sortie * ERREUR HERES *
**Lets me type**(
2013-08-08 17:27:26.121 HMDAI[10989:303] How old are you currently?
3)
**Does by itself**(
2013-08-08 17:27:43.854 HMDAI[10989:303] You entered 0
2013-08-08 17:27:43.854 HMDAI[10989:303] What month is it? (Number)
2013-08-08 17:27:43.855 HMDAI[10989:303] you entered 0
2013-08-08 17:27:43.855 HMDAI[10989:303] What day is it? (Number)
2013-08-08 17:27:43.855 HMDAI[10989:303] You entered 0
2013-08-08 17:27:43.856 HMDAI[10989:303] You are 0 days old
)
Qu'est-ce que je fait de mal? J'ai utilisé XCode si cela aide.
Vous avez oublié de nous indiquer l'erreur. Vous pourriez également nous aider un peu en nous disant où l'erreur s'est produite. –
Beaucoup d'informations pour résoudre la question; vous avez juste besoin d'être un coude unix pour connaître la réponse. Heureusement, je n'ai pas rasé cette semaine ... – bbum