Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
December 10, 2018, 03:54:50 PM *
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 3.7 another example  (Read 1655 times)
SpecialOpZ
Newbie
*
Posts: 1


« on: June 02, 2014, 05:05:04 PM »

#import <Foundation/Foundation.h>

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

@interface TwoPoints : NSObject

- (void) print;
- (void) setXPoint: (int)x;
- (void) setYPoint: (int)y;
- (int) YPoint;
- (int) XPoint;


@end

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

@implementation TwoPoints

{
    int XPoint, YPoint;
}

- (void) print;
{
    NSLog(@" %i and %i", XPoint, YPoint);
}

- (void)setXPoint:(int)x
{
    XPoint = x;
}

- (void)setYPoint:(int)y
{
    YPoint = y;
}

- (int) XPoint
{
    return XPoint;
}

- (int) YPoint
{
    return YPoint;
}

@end

// ---- Program ----


int main(int argc, const char * argv[])
{

    @autoreleasepool {
       
        // Create an instance
       
        TwoPoints *crazyPoints = [[TwoPoints alloc]init];
       
       
        [crazyPoints setXPoint: 22];
        [crazyPoints setYPoint:-10];
       
        NSLog(@"The value of my points are crazy, they are: %i and %i", [crazyPoints XPoint], [crazyPoints YPoint]);
    }
    return 0;
}
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.