summaryrefslogtreecommitdiff
path: root/DSACore/Auxiliary/Calculator/Argument.cs
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-09-26 20:51:37 +0200
committerTrueDoctor <d-kobert@web.de>2018-09-26 20:51:37 +0200
commitb411aa2128c2724bec0ecedb8cb4e1ffa59f3b53 (patch)
tree14e0a0cca2cf66b95fda402c8c7d7b6bd5b7b222 /DSACore/Auxiliary/Calculator/Argument.cs
parent92e8bb7523c775014ccf68355e3f0178ebf4a61c (diff)
disconnected most vital calles from the Discord Bot
Diffstat (limited to 'DSACore/Auxiliary/Calculator/Argument.cs')
-rw-r--r--DSACore/Auxiliary/Calculator/Argument.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/DSACore/Auxiliary/Calculator/Argument.cs b/DSACore/Auxiliary/Calculator/Argument.cs
new file mode 100644
index 0000000..2379bfe
--- /dev/null
+++ b/DSACore/Auxiliary/Calculator/Argument.cs
@@ -0,0 +1,38 @@
+namespace DiscoBot.Auxiliary.Calculator
+{
+ using System;
+
+ /// <summary>
+ /// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int.
+ /// </summary>
+ public class Argument : ISolvable
+ {
+ private readonly int value;
+
+ public Argument(string value)
+ {
+ // check whether the value given is an empty string
+ if (string.IsNullOrEmpty(value))
+ {
+ throw new ArgumentException("Argument kann nicht mit einem leeren string instanziert werden. ", nameof(value));
+ }
+
+ if (!int.TryParse(value, out int result))
+ {
+ throw new ArgumentException($"Kann {value} nicht in Integer konvertieren");
+ }
+
+ this.value = result;
+ }
+
+ public int Solve()
+ {
+ return this.value;
+ }
+
+ public override string ToString()
+ {
+ return this.value.ToString();
+ }
+ }
+} \ No newline at end of file