-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import <stdio.h> | ||
|
||
int main(int argc, const char *argv[]){ | ||
printf("hello\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import <Foundation/NSObject.h> | ||
|
||
@interface Fraction: NSObject { | ||
int numerator; | ||
int denominator; | ||
} | ||
|
||
-(void) print; | ||
-(void) setNumerator: (int) n; | ||
-(void) setDenominator: (int) d; | ||
-(int) numerator; | ||
-(int) denominator; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import "Fraction.h" | ||
#import <stdio.h> | ||
|
||
@implementation Fraction | ||
-(void) print { | ||
printf( "%i/%i", numerator, denominator ); | ||
} | ||
|
||
-(void) setNumerator: (int) n { | ||
numerator = n; | ||
} | ||
|
||
-(void) setDenominator: (int) d { | ||
denominator = d; | ||
} | ||
|
||
-(int) denominator { | ||
return denominator; | ||
} | ||
|
||
-(int) numerator { | ||
return numerator; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#import <stdio.h> | ||
#import "Fraction.h" | ||
|
||
int main( int argc, const char *argv[] ) { | ||
// create a new instance | ||
Fraction *frac = [[Fraction alloc] init]; | ||
|
||
// set the values | ||
[frac setNumerator: 1]; | ||
[frac setDenominator: 3]; | ||
|
||
// print it | ||
printf( "The fraction is: " ); | ||
[frac print]; | ||
printf( "\n" ); | ||
|
||
// free memory | ||
[frac release]; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
run: | ||
gcc -c Fraction.m -I /usr/include/GNUstep/ | ||
gcc main.m Fraction.o -o s -I /usr/include/GNUstep/ | ||
./s |