Amazon.com Widgets My solution for Exercises 3.7
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 19, 2013, 06:58:33 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Programming in Objective-C, 4th edition
| |-+  Exercises
| | |-+  Chapter 3
| | | |-+  My solution for Exercises 3.7
Pages: [1]   Go Down
Print
Author Topic: My solution for Exercises 3.7  (Read 194 times)
ziou2004
Newbie
*
Posts: 1


Email




« on: January 28, 2013, 09:45:49 AM »

This is my solution for Exercises 3.7 about coordinate. Runing is no issue。

Code: (Objective-C)
//
//  main.m
//  coordinate
//
//  Created by juzhong on 13-1-28.
//  Copyright (c) 2013年 juzhong. All rights reserved.
//

#import <Foundation/Foundation.h>

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

@interface Coordinate : NSObject


-(void) setCoordinate_X: (int) x;
-(void) setCoordinate_Y: (int) y;
-(int)  getCoordinate_X;
-(int)  getCoordinate_y;


@end

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

@implementation Coordinate

{
    int c_X;
    int c_Y;
}



-(void) setCoordinate_X:(int)x
{
    c_X=x;
}

-(void) setCoordinate_Y:(int)y
{
    c_Y=y;
}

-(int) getCoordinate_X
{
    return c_X;
}

-(int) getCoordinate_y
{
    return c_Y;
}
@end

//---- Program part ----

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

    @autoreleasepool {
       
        Coordinate *myCoordinate=[Coordinate alloc];
        myCoordinate=[myCoordinate init];
       
       
       
        //Set coordinate
       
        [myCoordinate setCoordinate_X:100];
        [myCoordinate setCoordinate_Y:200];
       
        //Print coordinate
        NSLog(@"The coordinate is (%i,%i)",[myCoordinate getCoordinate_X],[myCoordinate getCoordinate_y]);
       
               
       
    }
    return 0;
}
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

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 (c) 2009 classroomM.com. All rights reserved.