Browse files

Move Add into Integer

Much like the IsEqual, the behavior of adding two integers can be moved onto the Integer class. This allows us to then just Add integers instead of newing up a Sum class.
  • Loading branch information...
Fyzxs committed Jun 20, 2018
1 parent ab816ac commit 64bab66e487d59f09305539e74d0b1d3399b3346
Showing with 2 additions and 1 deletion.
  1. +2 −1 AddTwoInts/AddTwoIntsTests.cs
@@ -12,7 +12,7 @@ public void ShouldReturnSumOfTwoInts()
Integer expected = new IntegerOf(9);
Integer augend = new IntegerOf(4);
Integer addend = new IntegerOf(5);
Integer subject = new Sum(augend, addend);
Integer subject = augend.Add(addend);

@@ -25,6 +25,7 @@ public abstract class Integer
public static implicit operator int(Integer origin) => origin.Value();
protected abstract int Value();
public Bool IsEqual(Integer other) => new IntegerEquality(this, other);
public Integer Add(Integer addend) => new Sum(this, addend);

public sealed class IntegerOf : Integer

0 comments on commit 64bab66

Please sign in to comment.