Objective-C Programming (Sixth Edition) Chapter 3 answers to exercises

Source: Internet
Author: User

1. invalid: 6_05 (cannot begin with a number)

A $ ($ is an invalid symbol ).

2. mybook (openbook, closebook, readbook, takebook, putbook ).

3. [mybook takebook];

[Mybook openbook];

[Mybook readbook];

[Mybook closebook];

[Mybook putbook];

4. [myboat driver];

[Mymotorcycle driver];

[Mycar driver];

Overlap.

5. Ease and reduce the memory (I understand that the question is not too clear ).

6. Understand the advantages and disadvantages of Procedural language and object-oriented language.

7.

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

#import <Foundation / Foundation.h>

@interface XYpoint: NSObject

-(void) setXcoordinate: (int) x;

-(void) setYcoordinate: (int) y;

-(int) xCoordinate;

-(int) yCoordinata;

@end


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

#import "XYpoint.h"

@implementation XYpoint
{
    int xCoordinate;
    int yCoordinate;
}

-(void) setXcoordinate: (int) x
{
    xCoordinate = x;
}

-(void) setYcoordinate: (int) y
{
    yCoordinate = y;
}

-(int) xCoordinate
{
    return xCoordinate;
}

-(int) yCoordinata
{
    return yCoordinate;
}

@end


// ------------- program part ------------

#import <Foundation / Foundation.h>
// Remember to import the header file of the class
#import "XYpoint.h"

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

    @autoreleasepool {
        
        // insert code here ...
        XYpoint * newCoordinate = [[XYpoint alloc] init];
        
        [newCoordinate setXcoordinate: 12];
        [newCoordinate setYcoordinate: 15];
        
        NSLog (@ "newCoordinate is (% d,% d)", [newCoordinate xCoordinate], [newCoordinate yCoordinata]);
        
        
    }
    return 0;
}


// The input result is as follows: 

16:34:18. 511 prog1 [3284: 303] newcoordinate is)

 

Program ended with exit code: 0

 

 

Objective-C Programming (Sixth Edition) Chapter 3 answers to exercises

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.