Reorganized File Structure
Added Documentation
This commit is contained in:
49
MathKit/MPProductTerm.m
Normal file
49
MathKit/MPProductTerm.m
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// MPProductTerm.m
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 15.11.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPProductTerm.h"
|
||||
|
||||
#import "MPParsedExpression.h"
|
||||
#import "MPPowerFunction.h"
|
||||
|
||||
#import "MPFunctionTerm.h"
|
||||
#import "MPElementaryFunctionTerm.h"
|
||||
#import "MPNumber.h"
|
||||
#import "MPFactorialTerm.h"
|
||||
#import "MPPowerTerm.h"
|
||||
#import "MPVariable.h"
|
||||
|
||||
#import "MPToken.h"
|
||||
|
||||
@implementation MPProductTerm
|
||||
|
||||
- (instancetype)initWithFactors:(NSArray *)factors
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSAssert(factors != nil, @"factors must not be nil.");
|
||||
NSAssert(factors.count > 0, @"factors must not be empty.");
|
||||
_factors = factors;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error
|
||||
{
|
||||
NSDecimalNumber *value = [NSDecimalNumber one];
|
||||
for (MPTerm *factor in self.factors) {
|
||||
NSDecimalNumber *currentValue = [factor evaluate:error];
|
||||
if (!currentValue) {
|
||||
return nil;
|
||||
}
|
||||
value = [value decimalNumberByMultiplyingBy:currentValue];
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user