xcode
의 계산기 클래스 작업에 문제가 있습니다. 코드를 참조 용으로 첨부했습니다. 나는 학습 단계에서 초보자이므로 모든 도움을 정말로 받아야한다. 오류는 불완전한 구현의 오류입니다.Xcode의 출력 오류
// Working with Calculator class
// What required shall be a class where we can perform 4 basic operations of +,-,/,* using accumulator which we can set to some value and perform operations on it and then also return its value, also clear it for some other operation.
#import <Foundation/Foundation.h>
@interface Calculator:NSObject
{
double accumulator;// type of variables employed
}
-(void) setAccumulator:(double)value; // Declaring the methods employed
-(void) clearAccumulator;
-(double) Accumulator;
// Method declaration for calculation - Arithematic Methods
-(void)subtract : (double) value;
-(void) add : (double) value;
-(void) multiply : (double) value;
-(void) divide : (double) value;
@end
@implementation Calculator // defining the methods declared in interface section
-(void) setAccuumulator:(double)value
{
accumulator=value;
}
-(void) clearAccumulator
{
accumulator = 0;
}
-(double) Accumulator
{
return accumulator;
}
-(void) subtract : (double)value
{
accumulator -= value;
}
-(void) add : (double) value
{
accumulator += value;
}
-(void) multiply : (double) value
{
accumulator *= value;
}
-(void) divide : (double) value
{
accumulator /= value;
}
@end
// Program section as usual begins with the main
int main(int argc, char*argv[])
{
NSAutoreleasePool * pool =[[NSAutoreleasePool alloc] init];
Calculator * deskCal = [[Calculator alloc] init];
[deskCal setAccumulator: 100.0];
[deskCal add :200.0];
[deskCal divide : 15.0];
[deskCal subtract : 10.0];
[deskCal multiply : 5.0];
NSLog(@" The result is %g", [deskCal Accumulator]);
[deskCal release];
[pool drain];
return 0;
}
'불완전한 구현'을 제공오류가 구현되지 않은 방법을 알려 주어야합니다 - 질문에 오류 출력을 추가 할 수 있습니까? – deanWombourne
@deanWombourne 그는 함수의 철자가 틀렸기 때문에'NSInvalid exception'을 얻고 있습니다. –
나는 함수에 관심이 많았습니다. 질문에서 그것을 볼 수 없었습니다. 당신이 그것을 본 것 같아 보이지만 :) 나는 또한 컴파일러가 잘못되었다고 말하고 있다는 것을 깨닫기를 원했다. – deanWombourne