**Thanks again steve.**

Here are the files

Code:

#import <Foundation/Foundation.h>
#import <objc/Object.h>
@interface Fraction : NSObject
{
int numerator;
int denominator;
}
@property int numerator, denominator;
-(void) print;
-(double) convertToNum;
-(void) setTo: (int) n over: (int) d;
-(id) add:(id) f;
-(Fraction *) subtract: (Fraction *) f;
-(Fraction *) multiply: (Fraction *) f;
-(Fraction *) divide: (Fraction *)f;
-(void) reduce;
@end

Code:

#import "Fraction.h"
@implementation Fraction
@synthesize numerator, denominator;
-(void) print
{
int whole, num2;
BOOL needToReduce;
if ( numerator >= denominator)
needToReduce = YES;
if (needToReduce == YES)
{
whole = numerator / denominator;
num2 = numerator % denominator;
if (numerator % denominator == 0)
NSLog(@" %i ", whole);
else
NSLog(@" %i %i/%i ", whole, num2, denominator);
}
else
NSLog(@" %i/%i ",numerator, denominator);
}
-(double) convertToNum
{
if ( denominator != 0 )
return (double) numerator / denominator;
else
return 1;
}
-(void) setTo: (int) n over: (int) d
{
numerator = n;
denominator = d;
}
-(id) add: (id) f
{ //add fractions together
// result stores the reult of the addition
Fraction *result = [[Fraction alloc] init];
double resultNum, resultDenom , fnum ;
if ( f < 0)
{
fnum = -1 * [f numerator];
resultNum = numerator * [f denominator ] - denominator * fnum ;
resultDenom = denominator * [f denominator];
[result setTo:resultNum over: resultDenom];
}
else
{
resultNum = numerator * [f denominator ] + (denominator * [ f numerator ]);
resultDenom = denominator * [ f denominator ];
[result setTo:resultNum over: resultDenom];
}
if (resultNum > resultDenom)
{
[result reduce];
}
return result;
}
-(Fraction *) subtract: (Fraction *) f
{
//subtract fractions
Fraction *result = [[Fraction alloc] init];
int resultNum1, resultNum2, resultDenom, resultNum;
if ( f < 0)
{
f.numerator = -1 * f.numerator;
resultNum1 =(numerator * f.denominator) ;
resultNum2 = (denominator * f.numerator);
resultDenom = (denominator * f.denominator);
resultNum = resultNum1 + resultNum2;
[result setTo:resultNum over: resultDenom];
}
else {
resultNum1 =(numerator * f.denominator) ;
resultNum2 = (denominator * f.numerator);
resultDenom = (denominator * f.denominator);
resultNum = resultNum1 - resultNum2;
[result setTo:resultNum over: resultDenom];
}
if (resultNum > resultDenom)
{
[result reduce];
}
return result;
}
-(Fraction *) multiply: (Fraction *) f
{
Fraction *result = [[Fraction alloc]init];
int resultNum, resultDenom;
if ( f < 0)
{
f.numerator = -1 * f.numerator;
resultNum = numerator * f.numerator;
resultDenom = denominator * f.denominator;
[result setTo:resultNum over: resultDenom];
}
else
{
resultNum = numerator * f.numerator;
resultDenom = denominator * f.denominator;
[result setTo:resultNum over: resultDenom];
}
if (resultNum > resultDenom)
{
result.reduce;
}
return result;
}
-(Fraction *) divide: (Fraction *)f
{
Fraction *result = [[Fraction alloc]init];
int resultNum, resultDenom;
resultNum = numerator * f.denominator;
resultDenom = denominator * f.numerator;
[result setTo:resultNum over: resultDenom];
if (resultNum > resultDenom)
{
result.reduce;
}
return result;
}
-(void) reduce
{
int u = numerator;
int v = denominator;
int temp;
while ( v != 0)
{
temp = u % v;
u = v;
v = temp;
}
numerator /= u;
denominator /= u;
}
@end

Code:

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@interface ComplexNumbers : NSObject
{
double real;
double imaginary;
}
@property double real, imaginary;
// methods
-(void) setReal : (double) a andImaginary: (double) b;
-(void) print; // to print as a + b(i)
-(id) add: (id) c;
@end

Code:

#import "Complex.h"
@implementation ComplexNumbers
@synthesize real, imaginary;
// define methods
-(id) add: (id) c
{
id result = [[ComplexNumbers alloc] init];
double r1, imag1;
r1 = real + [c real];
imag1 = imaginary + [c imaginary];
[result setReal:r1 andImaginary:imag1];
return result;
}
-(void) setReal: (double) a andImaginary: (double) b
{
real = a , imaginary = b;
}
-(void) print // print the equation
{
NSLog(@"(%g + %gi)", real, imaginary);
}
@end

Code:

#import <Foundation/Foundation.h>
#import "Fraction.h"
#import "Complex.h"
int main(int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
id result, dataValue2, dataValue1;
Fraction *f1 = [[Fraction alloc]init];
Fraction *f2 = [[Fraction alloc]init];
ComplexNumbers *c1 = [[ ComplexNumbers alloc] init];
ComplexNumbers *c2 = [[ ComplexNumbers alloc] init];
[f1 setTo:2 over:5];
[f2 setTo:5 over:8];
result = [ f1 add: f2];
[result print];
dataValue1 = f1;
dataValue2 = f2;
result = [ dataValue1 add: dataValue2 ];
[result print];
[c1 setReal: 10 andImaginary: 2.5 ];
[c2 setReal: 14 andImaginary: 3];
result = [ c1 add: c2 ];
[result print];
dataValue1 = c1;
dataValue2 = c2;
result = [ dataValue1 add: dataValue2 ];
[result print];
[result release];
[c1 release];
[c2 release];
[f2 release];
[f1 release];
[pool drain];
return 0;
}

i am using Xcode leopard 10.5

here is the debug

Code:

/users/lori/Desktop/Objectve c lessons/Rectangle/main.m: In function 'main':
/Users/lori/Desktop/Objectve c lessons/Rectangle/main.m:32: warning: multiple methods named '-add:' found
/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSObjectController.h:59: warning: using '-(void)add:(id)sender'
/Users/lori/Desktop/Objectve c lessons/Rectangle/Fraction.h:22: warning: also found '-(id)add:(id)f'
/Users/lori/Desktop/Objectve c lessons/Rectangle/main.m:32: error: void value not ignored as it ought to be
/Users/lori/Desktop/Objectve c lessons/Rectangle/main.m:46: warning: multiple methods named '-add:' found
/[B]Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSObjectController.h:59: warning: using '-(void)add:(id)sender'[/B]
/Users/lori/Desktop/Objectve c lessons/Rectangle/Fraction.h:22: warning: also found '-(id)add:(id)f'
/Users/lori/Desktop/Objectve c lessons/Rectangle/main.m:46: error: void value not ignored as it ought to be

does it look like an error in the framework file?