iOS应用设计模式开发中对简单工厂和工厂方法模式的运用

2020-01-14 22:13:39刘景俊

}

@end


加法类(运算子类):
接口文件:
复制代码
#import "Operation.h"

 

@interface OperationAdd:Operation
@end


实现文件:
复制代码
#import "OperationAdd.h"

 

@implementation OperationAdd

-(double) GetResult{
    double result =0;
    result =numberA+numberB;
    return result;
}

@end


减法类(运算子类):
接口文件:
复制代码
#import "Operation.h"
@interface OperationSub:Operation
@end
实现文件:
复制代码
#import "OperationSub.h"

 

@implementation OperationSub

-(double)GetResult{
    double result =0;
    result = numberA-numberB;
    return result;
}

@end


乘法类(运算子类)
复制代码
#import "Operation.h"
@interface OperationMul:Operation
@end
实现文件: