Arithmetic/Rational/Objective-C: Difference between revisions
Content added Content deleted
m (modernize) |
No edit summary |
||
Line 1: | Line 1: | ||
{{collection|Rational Arithmetic}} |
|||
File <tt>frac.h</tt> |
|||
<syntaxhighlight lang="objective-c"> |
|||
#import <Foundation/Foundation.h> |
|||
@interface RCRationalNumber : NSObject |
@interface RCRationalNumber : NSObject |
||
Line 46: | Line 47: | ||
-(double)number; |
-(double)number; |
||
-(int)integer; |
-(int)integer; |
||
@end</ |
@end</syntaxhighlight> |
||
;File <tt>frac.m</tt> |
;File <tt>frac.m</tt> |
||
⚫ | |||
<syntaxhighlight lang="objective-c"> |
|||
⚫ | |||
#import <math.h> |
#import <math.h> |
||
#import "frac.h" |
#import "frac.h" |
||
Line 271: | Line 274: | ||
return [[self alloc] initWithRational: rnum]; |
return [[self alloc] initWithRational: rnum]; |
||
} |
} |
||
@end</ |
@end</syntaxhighlight> |
||
;Testing |
;Testing |
||
<syntaxhighlight lang="objective-c"> |
|||
#import <Foundation/Foundation.h> |
|||
#import "frac.h" |
#import "frac.h" |
||
#import <math.h> |
#import <math.h> |
||
Line 303: | Line 308: | ||
} |
} |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |