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