#import <Foundation/Foundation.h>
@interface Phone:nsobject
{
@public
NSString *_brand;
NSString *_model;
NSString *_color;
float _size;
NSString *_cpu;
}
-(void) aboutmyphone;
Aboutmyphone;
Call.
-(void) Callwithnumber: (NSString *) number;
Callwithnumber:
Texting
-(void) SendMessage: (NSString *) message Tonumber: (NSString *) number;
Sendmessage:tonumber:
@end
@implementation Phone
-(void) Aboutmyphone
{
NSLog (@ "\ n Brand:%@\n model:%@\n color:%@\n Size:%.2f\ncpu:%@",
_brand,_model,_color,_size,_cpu
);
}
-(void) Callwithnumber: (NSString *) number
{
NSLog (@ "Calling%@", number);
}
-(void) SendMessage: (NSString *) message Tonumber: (NSString *) number
{
NSLog (@ "Sending SMS"%@ "to"%@ ", Message,number);
}
@end
Name: Xiao Wang
Age: 19
int main (int argc, const char * argv[])
{
Phone *iphone = [phone new];
Iphone->_brand = @ "Apple";
Iphone->_color = @ "Local tyrants gold";
IPHONE->_CPU = @ "A7";
Iphone->_model = @ "IPhone 8S";
Iphone->_size = 7.9f;
[IPhone Aboutmyphone];
[IPhone callwithnumber:@ "10086"];
[IPhone sendmessage:@] See you at the old place tonight! "tonumber:@" 110 ";
return 0;
}
OC Foundation The second day class and object---1 review code