I just can’t get tests 7 and 8 to pass (7 is returning True instead of the expected False, 8 is returning False instead of the expected True), can anyone assist? I tried to post in Discord, but the code goes over the character limit there, and I don’t want to leave any out, as I’m not sure what’s causing the issue.
public class FacialFeatures
{
public string EyeColor { get; }
public decimal PhiltrumWidth { get; }
public FacialFeatures(string eyeColor, decimal philtrumWidth)
{
EyeColor = eyeColor;
PhiltrumWidth = philtrumWidth;
}
// TODO: implement equality and GetHashCode() methods
public override bool Equals(object obj) => this.Equals(obj as FacialFeatures);
public bool Equals(FacialFeatures face)
{
return EyeColor == face.EyeColor && PhiltrumWidth == face.PhiltrumWidth;
}
public int GetHashCode()
{
return (EyeColor, PhiltrumWidth).GetHashCode();
}
}
public class Identity
{
public string Email { get; }
public FacialFeatures FacialFeatures { get; }
public Identity(string email, FacialFeatures facialFeatures)
{
Email = email;
FacialFeatures = facialFeatures;
}
// TODO: implement equality and GetHashCode() methods
public override bool Equals(object obj) => this.Equals(obj as Identity);
public bool Equals(Identity ident)
{
return Email == ident.Email && FacialFeatures.Equals(ident.FacialFeatures);
}
public int GetHashCode()
{
return (Email, FacialFeatures).GetHashCode();
}
}
public class Authenticator
{
private readonly HashSet<Identity> uniqueFaces = new HashSet<Identity>();
public static bool AreSameFace(FacialFeatures faceA, FacialFeatures faceB) => faceA.Equals(faceB);
public bool IsAdmin(Identity identity)
{
var adminIdent = new Identity("admin@exerc.ism", new FacialFeatures("green", 0.9m));
return identity.Equals(adminIdent);
}
public bool Register(Identity identity) => uniqueFaces.Contains(identity) ? false : uniqueFaces.Add(identity);
public bool IsRegistered(Identity identity) => uniqueFaces.Contains(identity);
public static bool AreSameObject(Identity identityA, Identity identityB)
{
return System.Object.ReferenceEquals(identityA, identityB);
}
}