对象作为参数的连续传递(有点乱。。)

/*

 

 双十一在淘宝买了件衣服

 

 

 衣服类

 属性:品牌、类型、颜色、大小

 行为:使人变帅

 

 快递类

 属性:品牌、速度、价格

 行为:收快递、送快递

 

 收件人类

 属性:姓名、身高、年龄、体重

 行为:接受快递,穿衣服

 

 

 */



#import <Foundation/Foundation.h>

#import "Recipients.h"




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

    @autoreleasepool {

        Clothes *cl=[Clothes new];

        cl->_brand=@"韩都衣舍";

        cl->_type=@"外套";

        cl->_color=@"黑色";

        cl->_size=29;

        Courier *cu=[Courier new];

        Recipients *r= [Recipients new];

        [r show:cu and:cl];

     }

    return 0;

}

//  Recipients.h

//  OC02

//

//  Created by Devil on 15/11/1.


//收件人类

//属性:姓名、身高、年龄、体重

//行为:接受快递,穿衣服

#import <Foundation/Foundation.h>

#import "Courier.h"

@interface Recipients : NSObject{

@public

    NSString *_name;

    float _height;

    int _age;

    float _weight;

}

-(void)acc:(Courier *)co and:(Clothes *)c;

-(void)show:(Courier *)co and:(Clothes *)c;


@end



//  Recipients.m

//  OC02

//  Created by Devil on 15/11/1.

#import "Recipients.h"



@implementation Recipients

-(void)acc:(Courier *)co and:(Clothes *)c{

    [co deli:c];

}

-(void)show:(Courier *)co and:(Clothes *)c{

[co deli:c];

}


@end


//  Courier.h

//  OC02

//  Created by Devil on 15/11/1.

//快递类

//属性:品牌、速度、价格

//行为:收快递、送快递

#import <Foundation/Foundation.h>

#import "Clothes.h"

@interface Courier : NSObject{

@public

    NSString *_brand;

    int _days;

    int _prices;

}

-(void)accept:(Clothes *)c;


-(void)deli:(Clothes *)c;


@end



//  Courier.m

//  OC02

//  Created by Devil on 15/11/1.

#import "Courier.h"


@implementation Courier

-(void)accept:(Clothes *)c{

    NSLog(@"接受一件 %@%@%@%d",c->_brand,c->_type,c->_color,c->_size);

}

-(void)deli:(Clothes *)c{

NSLog(@"发送一件 %@%@%@%d",c->_brand,c->_type,c->_color,c->_size);

}

@end

//  Clothes.h

//  OC02

//  Created by Devil on 15/11/1.

衣服类

//属性:品牌、类型、颜色、大小

//行为:使人变帅

#import <Foundation/Foundation.h>

@interface Clothes : NSObject{

@public

    NSString *_brand;

    NSString *_type;

    NSString *_color;

    char _size;

}

-(void)beaut;

@end


//  Clothes.m

//  OC02

//  Created by Devil on 15/11/1.

#import "Clothes.h"


@implementation Clothes

    -(void)beaut{

    NSLog(@"这衣服真帅");

    }

@end




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值