/*
双十一在淘宝买了件衣服
衣服类
属性:品牌、类型、颜色、大小
行为:使人变帅
快递类
属性:品牌、速度、价格
行为:收快递、送快递
收件人类
属性:姓名、身高、年龄、体重
行为:接受快递,穿衣服
*/
#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