码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-07-16 02:08:40      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

 

#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(@"\n品牌:%@\n型号:%@\n颜色:%@\n尺寸:%.2f\nCPU:%@",

          _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;

}

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

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!