Skip to content

Commit

Permalink
feat: added scaffolding to addition func
Browse files Browse the repository at this point in the history
update #2
  • Loading branch information
rishiosaur committed Dec 28, 2019
1 parent 6880534 commit 6cb600a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/equations/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,53 @@ class Expression implements NormalExpression {
subtract(expression: Expression): Expression {
return this
}
private static negateDistributableOperator(
operator: DistributableOperator
): DistributableOperator {
// VSCode will throw an error, stating that it's being used without being defined.
let returnOperator: DistributableOperator = DistributableOperator.Subtract
switch (operator) {
case DistributableOperator.Add:
returnOperator = DistributableOperator.Subtract
break

case DistributableOperator.Subtract:
returnOperator = DistributableOperator.Add
break

default:
break
}

return returnOperator
}
static distributeOperators(expression: Expression, operator: DistributableOperator) {
expression.terms.forEach((term, index) => {
switch (expression.operator) {
case Operator.Add:
break

case Operator.Subtract:
expression.terms[index].operator = Expression.negateDistributableOperator(
(expression.operator as unknown) as DistributableOperator
)
break

case Operator.Multiply:
break

case Operator.Divide:
break

default:
break
}
})
return true
}
static canBeSimplified(expression: Expression): Boolean {
return true
}
}

export default Expression

0 comments on commit 6cb600a

Please sign in to comment.