oc基础第二天类与对象---1复习代码

#import <Foundation/Foundation.h>

@interface Phone : NSObject

{

   @public

    NSString *_brand;

    NSString *_model;

    NSString *_color;

    float _size;

    NSString *_cpu;

}

- (void)aboutMyPhone;

//aboutMyPhone;

//打电话.

- (void)callWithNumber:(NSString *)number;

//callWithNumber:

//发短信

- (void)sendMessage:(NSString *)message toNumber:(NSString *)number;

//sendMessage: toNumber:

@end

@implementation Phone

- (void)aboutMyPhone

{

    NSLog(@" 品牌:%@ 型号:%@ 颜色:%@ 尺寸:%.2f CPU:%@",

          _brand,_model,_color,_size,_cpu

          );

}

- (void)callWithNumber:(NSString *)number

{

    NSLog(@"正在呼叫%@",number);

}

- (void)sendMessage:(NSString *)message toNumber:(NSString *)number

{

    NSLog(@"正在发送短信【%@】给【%@】",message,number);

}

@end

//姓名:小王

//年龄:19

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

{

    

    Phone *iPhone = [Phone new];

    iPhone->_brand = @"Apple";

    iPhone->_color = @"土豪金";

    iPhone->_cpu = @"A7";

    iPhone->_model = @"iPhone 8S";

    iPhone->_size = 7.9f;

    

    [iPhone aboutMyPhone];

    [iPhone callWithNumber:@"10086"];

    [iPhone sendMessage:@"今天晚上老地方见!" toNumber:@"110"];

    

    

    

    return 0;

}

原文地址:https://www.cnblogs.com/qjrz/p/4649927.html