All pastes #922802 Raw Edit

GrooveMachine

public text v1 · immutable
#922802 ·published 2008-02-29 01:07 UTC
rendered paste body
#import <stdio.h>
#import <objc/Object.h>

//-------- @interface section --------

@interface Point: Object
{
	int pointX;
	int pointY;
}
-(void) print;
-(void) setPointX: (int) x;
-(void) setPointY: (int) y;

@end

//-------- @implementation section --------

@implementation Point;
-(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[])
{
	Point *point1 = [[Point alloc] init];
	Point *point2 = [[Point 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;
}