Am trying to add subtraction function to my code below. Am learning how to code and I am stumped in a way to integrate addition and subtraction. Thanks for any help.
Code:
#import <Foundation/Foundation.h>
//---- @interface section----
@interface SimpleCalc: NSObject
{
int number1;
int number2;
}
-(void) setNumber1: (int) n1;
-(void) setnumber2: (int) n2;
-(int) addition;
@end
//---- @implementation section----
@implementation SimpleCalc
-(void) setNumber1:(int)n1
{
number1 = n1;
}
-(void) setnumber2:(int)n2
{
number2 = n2;
}
-(int) addition
{
return number1+number2;
}
@end
//----program section----
int main (int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
//----addition functionality----
SimpleCalc *myCalc;
myCalc = [SimpleCalc alloc];
myCalc = [myCalc init];
[myCalc setNumber1:30];
[myCalc setnumber2:30];
//message
NSLog (@"The Addition of two numbers= %i", [myCalc addition]);
[pool drain];
return 0;
}