summaryrefslogtreecommitdiff
path: root/DSALib/Auxiliary/Calculator/Operator.cs
diff options
context:
space:
mode:
authoruzvkl <dennis.kobert@student.kit.edu>2019-06-11 23:05:52 +0200
committeruzvkl <dennis.kobert@student.kit.edu>2019-06-11 23:05:52 +0200
commite6181c24124d97f2fbc932b8a68311e625463156 (patch)
treec1f097c344ca266b7941c9668590b0fd35c7870a /DSALib/Auxiliary/Calculator/Operator.cs
parent2490ad5d31fe2ac778ff9303776f0e91f47a2862 (diff)
Move dsa related stuff to subfolder
Diffstat (limited to 'DSALib/Auxiliary/Calculator/Operator.cs')
-rw-r--r--DSALib/Auxiliary/Calculator/Operator.cs51
1 files changed, 0 insertions, 51 deletions
diff --git a/DSALib/Auxiliary/Calculator/Operator.cs b/DSALib/Auxiliary/Calculator/Operator.cs
deleted file mode 100644
index e6aeec6..0000000
--- a/DSALib/Auxiliary/Calculator/Operator.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using DSALibv.Auxiliary.Calculator;
-
-namespace DSALib.Auxiliary.Calculator
-{
- /// <summary>
- /// The Operator Class represents a binary operator with tow Arguments and an Operation type
- /// </summary>
- public class Operator : ISolvable
- {
- private readonly ISolvable arg1, arg2;
-
- public Operator(ISolvable arg1, ISolvable arg2, Ops operatorType)
- {
- this.arg1 = arg1;
- this.arg2 = arg2;
- OperatorType = operatorType;
- }
-
- public Ops OperatorType { get; set; }
-
- public int Solve()
- {
- int result;
- switch (OperatorType)
- {
- case Ops.Dice:
- result = Dice.Roll(arg1.Solve(), arg2.Solve());
- break;
- case Ops.Multiply:
- result = arg1.Solve() * arg2.Solve();
- break;
- case Ops.Add:
- result = arg1.Solve() + arg2.Solve();
- break;
- case Ops.Subtract:
- result = arg1.Solve() - arg2.Solve();
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
-
- return result;
- }
-
- public override string ToString()
- {
- return $"({arg1} {OperatorType} {arg2})";
- }
- }
-} \ No newline at end of file