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

    }

  • 相关阅读:
    1245. Tree Diameter
    771. Jewels and Stones
    830. Positions of Large Groups
    648. Replace Words
    647. Palindromic Substrings
    435. Non-overlapping Intervals
    646. Maximum Length of Pair Chain
    645. Set Mismatch
    242. Valid Anagram
    438. Find All Anagrams in a String
  • 原文地址:https://www.cnblogs.com/qjrz/p/4649927.html
Copyright © 2020-2023  润新知