// // main.m // Exercise // // Created by Gus Bendinelli on 2/27/08. // Copyright Gus Bendinelli 2008. All rights reserved. // #import #import //-------- @interface section -------- @interface GMPoint: NSObject { int pointX; int pointY; } -(void) print; -(void) setPointX: (int) x; -(void) setPointY: (int) y; @end //-------- @implementation section -------- @implementation GMPoint -(void) print { printf (" %i,%i ", pointX, pointY); } -(void) setPointX: (int) x { pointX = x; } -(void) setPointY: (int) y { pointY = y; } @end //-------- program section -------- int main (int argc, char *argv[]) { GMPoint *point1 = [[GMPoint alloc] init]; GMPoint *point2 = [[GMPoint alloc] init]; //---- Set 1st coordinate to (2,3) ---- [point1 setPointX: 2]; [point1 setPointY: 3]; //---- Set 2nd coordinate to (4,5) ---- [point2 setPointX: 4]; [point2 setPointY: 5]; //---- Display the coordinates ---- printf ("The first coordinate is:"); [point1 print]; printf ("\n"); printf ("The second coordinate is:"); [point2 print]; printf ("\n"); [point1 free]; [point2 free]; return 0; }