#import <Foundation/Foundation.h>
#import "Fund.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
Fund *jijin = [[Fund alloc] init];
[jijin SellFound];
[jijin BuFund];
}
return 0;
}
//基金类
#import <Foundation/Foundation.h>
#import "Stock1.h"
#import "Stock2.h"
#import "Stock3.h"
#import "National1Debt1.h"
#import "Realty1.h"
@interface Fund : NSObject
-(void)BuFund;
-(void)SellFound;
@end
#import "Fund.h"
@implementation Fund
-(void)BuFund{
[Stock1 Buy];
[Stock2 Buy];
[Stock3 Buy];
[National1Debt1 Buy];
[Realty1 Buy];
}
-(void)SellFound{
[Stock1 Sell];
[Stock2 Sell];
[Stock3 Sell];
[National1Debt1 Sell];
[Realty1 Sell];
}
@end
#import <Foundation/Foundation.h>
@interface Stock1 : NSObject
//卖股票方法
+(void)Sell;
//买股票的方法
+(void)Buy;
@end
#import "Stock1.h"
@implementation Stock1
//买股票方法的实现
+(void)Sell{
NSLog(@"股票1卖出");
}
+(void)Buy{
NSLog(@"股票1买入");
}
@end
#import <Foundation/Foundation.h>
@interface Stock2 : NSObject
//卖股票方法
+(void)Sell;
//买股票的方法
+(void)Buy;
@end
#import "Stock2.h"
@implementation Stock2
+(void)Sell{
NSLog(@"股票2卖出");
}
+(void)Buy{
NSLog(@"股票2买入");
}
@end
#import <Foundation/Foundation.h>
@interface Stock3 : NSObject
//卖股票方法
+(void)Sell;
//买股票的方法
+(void)Buy;
@end
#import "Stock3.h"
@implementation Stock3
+(void)Sell{
NSLog(@"股票3卖出");
}
+(void)Buy{
NSLog(@"股票3买入");
}
@end
#import <Foundation/Foundation.h>
@interface National1Debt1 : NSObject
//买国债的方法
+(void)Sell;
//买国债的方法
+(void)Buy;
@end
#import "National1Debt1.h"
@implementation National1Debt1
+(void)Sell{
NSLog(@"国债1卖出");
}
+(void)Buy{
NSLog(@"国债1买入");
}
@end
#import <Foundation/Foundation.h>
@interface Realty1 : NSObject
//买房地产的方法
+(void)Sell;
//买房地产的方法
+(void)Buy;
@end
#import "Realty1.h"
@implementation Realty1
+(void)Sell{
NSLog(@"房地产1卖出");
}
+(void)Buy{
NSLog(@"房地产1买入");
}
@end
原文:http://www.cnblogs.com/liumu/p/5245691.html