import { IMathOperationActor } from "./MathOperationActor" ; import { MathOperation } from "./MathOperations" ; import { AdditionOperationActor } from "./OperationActors/AdditionOperationActor" ; import { SubtractionOperationActor } from "./OperationActors/SubtractionOperationActor" ; /**
 * Converts simple math operations to the simplest possible strings.
 */ export class MathResolver { /**
     * Actors to resolve operations, keyed by operation type.
     */ private static operationActors : { [ i ] : IMathOperationActor ; } = { [ MathOperation . Addition ] : new AdditionOperationActor ( ) , [ MathOperation . Subtraction ] : new SubtractionOperationActor ( ) , } ; param left param operation param right returns public resolve ( left , operation , right ) { const actor = MathResolver . operationActors [ operation ] ; const leftInt = parseInt ( left , 10 ) ; const rightInt = parseInt ( right , 10 ) ; if ( ! isNaN ( leftInt ) && ! isNaN ( rightInt ) ) { return actor . resolve ( leftInt , rightInt ) ; } return left + actor . getDefaultAlias ( ) + right ; } }