Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
July 23, 2018, 12:47:24 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Exercise 7  (Read 1436 times)
mdziedzic
Newbie
*
Posts: 41



WWW
« on: September 25, 2009, 06:10:13 PM »

Exercise 7

Code: (Objective-C)

#import <Foundation/Foundation.h>



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

@interface XYPoint: NSObject
{
int xCoord;
int yCoord;
}

-(void)  setXCoord: (int) x;
-(void)  setYCoord: (int) y;
-(int)    xCoord;
-(int)    yCoord;

@end



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

@implementation XYPoint

-(void) setXCoord: (int) x
{
xCoord = x;
}

-(void) setYCoord: (int) y
{
yCoord = y;
}

-(int) xCoord
{
return xCoord;
}

-(int) yCoord
{
return yCoord;
}

@end



// ------------------------------------------- main ---------------- //

int main (int argc, const char * argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

XYPoint *myPoint = [XYPoint new];

[myPoint setXCoord: 42];
[myPoint setYCoord: 666];

NSLog(@"The coordinates of the point: (%i,%i)",
  [myPoint xCoord], [myPoint yCoord]);


[myPoint release];

        [pool drain];
        return 0;
}

The coordinates of the point: (42,666)

Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.