Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81709 / JSCompiler.Core / NumToken.cs
diff options
context:
space:
mode:
1 files changed, 42 insertions, 0 deletions
-rw-r--r--homework/81709/JSCompiler.Core/NumToken.cs42
diff --git a/homework/81709/JSCompiler.Core/NumToken.cs b/homework/81709/JSCompiler.Core/NumToken.cs
new file mode 100644
index 0000000..53af034
--- /dev/null
+++ b/homework/81709/JSCompiler.Core/NumToken.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JSCompiler.Core
+{
+ public class NumToken : Token, IEquatable<NumToken>
+ {
+ public NumToken(long num) : base(TokenType.Number)
+ {
+ Num = num;
+ }
+
+ public long Num { get; private set; }
+
+ public bool Equals(NumToken other)
+ {
+ return other.Num == Num && base.Equals((Token)other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ var item = obj as NumToken;
+
+ if (item == null) return false;
+
+ return Equals(item);
+ }
+
+ public override int GetHashCode()
+ {
+ return Num.GetHashCode() * 17 + base.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return Num.ToString();
+ }
+ }
+}