Skip to content

Commit

Permalink
Implementing IEquatable
Browse files Browse the repository at this point in the history
  • Loading branch information
mstama committed Jul 4, 2017
1 parent e10a2c8 commit 2106f00
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Merchant/Models/RomanDigits/RomanDigit.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Merchant.Exceptions;
using System;

namespace Merchant.Models
{
/// <summary>
/// Provides Roman Digits representation and associated meta-data
/// </summary>
public abstract class RomanDigit
public abstract class RomanDigit : IEquatable<RomanDigit>
{
/// <summary>
/// Contains the subtotal value
Expand Down Expand Up @@ -70,7 +71,12 @@ public override bool Equals(object obj)
{
var number = obj as RomanDigit;
if (number == null) { return false; }
return Value == number.Value;
return Equals(number);
}

public bool Equals(RomanDigit other)
{
return Value == other.Value;
}

public override int GetHashCode()
Expand Down

0 comments on commit 2106f00

Please sign in to comment.