|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Model
|
|
|
|
|
{
|
|
|
|
|
public class NumberDie : Die
|
|
|
|
|
public class NumberDie : Die, IEquatable<NumberDie>
|
|
|
|
|
{
|
|
|
|
|
private int min;
|
|
|
|
|
private int max;
|
|
|
|
@ -27,7 +27,7 @@ namespace Model
|
|
|
|
|
{
|
|
|
|
|
return min;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
min = value;
|
|
|
|
|
}
|
|
|
|
@ -38,33 +38,44 @@ namespace Model
|
|
|
|
|
{
|
|
|
|
|
return max;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
private set
|
|
|
|
|
{
|
|
|
|
|
max = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public override int RandomFace()
|
|
|
|
|
{
|
|
|
|
|
int resultat = random.Next(min, max + 1);
|
|
|
|
|
return resultat;
|
|
|
|
|
if (min < max)
|
|
|
|
|
{
|
|
|
|
|
int resultat = random.Next(min, max + 1);
|
|
|
|
|
return resultat;
|
|
|
|
|
}
|
|
|
|
|
else throw new ArgumentException("le min doit etre inferieur de max ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals([AllowNull] NumberDie other)
|
|
|
|
|
{
|
|
|
|
|
return Name == other.Name && Min == other.Min && Max == other.Max;
|
|
|
|
|
return Name==other.Name && Min == other.Min && Max == other.Max;
|
|
|
|
|
}
|
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
|
{
|
|
|
|
|
//Check null
|
|
|
|
|
//Check si la reference passer est null
|
|
|
|
|
if (ReferenceEquals(obj, null)) return false;
|
|
|
|
|
//Check reference equality
|
|
|
|
|
//Check si reference passer is equality
|
|
|
|
|
if (ReferenceEquals(obj, this)) return true;
|
|
|
|
|
//Check types
|
|
|
|
|
//Check if types is equality
|
|
|
|
|
if (GetType() != obj.GetType()) return false;
|
|
|
|
|
return Equals(obj as NumberDie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return Name.GetHashCode() ^ Min.GetHashCode() ^ Max.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|