diff --git a/Sources/BowlingLib/Model/Equipe.cs b/Sources/BowlingLib/Model/Equipe.cs
index 23508c1..86098f0 100644
--- a/Sources/BowlingLib/Model/Equipe.cs
+++ b/Sources/BowlingLib/Model/Equipe.cs
@@ -11,7 +11,7 @@ namespace BowlingLib.Model
///
/// Classe Model Equipe
///
- public class Equipe
+ public class Equipe:IEquatable
{
#region Propiéters
public string Nom { get; private set; }
@@ -52,13 +52,7 @@ namespace BowlingLib.Model
public IEnumerable AjouterJoueurs(params Joueur[] joueurs)
{
List result = new();
- foreach (var a in joueurs)
- {
- if (AjouterJoueur(a))
- {
- result.Add(a);
- }
- }
+ result.AddRange(joueurs.Where(a => AjouterJoueur(a)));
return result;
@@ -92,12 +86,7 @@ namespace BowlingLib.Model
{
joueurs.Remove(joueur);
}
-
- ///
- /// retourner la liste non modifiable des joueurs de l'équipe
- ///
- ///
-
+
///
/// Fonction permettant de vérifier si un joueur existe déjà dans la liste (l'équipe)
@@ -110,6 +99,23 @@ namespace BowlingLib.Model
return true;
return false;
}
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(obj, null)) return false;
+ if (ReferenceEquals(obj, this)) return true;
+ if (GetType() != obj.GetType()) return false;
+ return Equals(obj as Equipe);
+ }
+
+ public override int GetHashCode()
+ {
+ return joueurs.GetHashCode();
+ }
+
+ public bool Equals(Equipe other)
+ {
+ return joueurs.Equals(other.joueurs);
+ }
#endregion
}
diff --git a/Sources/BowlingLib/Model/Frame.cs b/Sources/BowlingLib/Model/Frame.cs
index 1c2ebc8..c262279 100644
--- a/Sources/BowlingLib/Model/Frame.cs
+++ b/Sources/BowlingLib/Model/Frame.cs
@@ -11,7 +11,7 @@ namespace BowlingLib.Model
///
/// Classe Model Frame
///
- public class Frame
+ public class Frame:IEquatable
{
const int MAX_QUILLE = 10;
public int Numero
@@ -285,5 +285,23 @@ namespace BowlingLib.Model
this.IsFinished = true;
}
}
+
+ public bool Equals(Frame other)
+ {
+ return Numero.Equals(other.Numero);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(obj, null)) return false;
+ if (ReferenceEquals(obj, this)) return true;
+ if (GetType() != obj.GetType()) return false;
+ return Equals(obj as Frame);
+ }
+
+ public override int GetHashCode()
+ {
+ return Numero.GetHashCode();
+ }
}
}
diff --git a/Sources/BowlingLib/Model/Joueur.cs b/Sources/BowlingLib/Model/Joueur.cs
index af1132c..5e43d07 100644
--- a/Sources/BowlingLib/Model/Joueur.cs
+++ b/Sources/BowlingLib/Model/Joueur.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
+using System.Diagnostics;
namespace BowlingLib.Model
{
@@ -87,6 +88,11 @@ namespace BowlingLib.Model
parties.Add(p);
}
+ private string GetDebuggerDisplay()
+ {
+ return ToString();
+ }
+
#endregion
}
}
diff --git a/Sources/BowlingLib/Model/Partie.cs b/Sources/BowlingLib/Model/Partie.cs
index 5216a21..42e46df 100644
--- a/Sources/BowlingLib/Model/Partie.cs
+++ b/Sources/BowlingLib/Model/Partie.cs
@@ -10,7 +10,7 @@ namespace BowlingLib.Model
///
/// Classe Model Partie
///
- public class Partie
+ public class Partie:IEquatable
{
#region Propriétés
public ReadOnlyCollection Frames { get; }
@@ -96,6 +96,23 @@ namespace BowlingLib.Model
}
return score;
}
+
+ public bool Equals(Partie other)
+ {
+ return Joueur.Equals(Joueur) && Date.Equals(other.Date);
+ }
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(obj, null)) return false;
+ if (ReferenceEquals(obj, this)) return true;
+ if (GetType() != obj.GetType()) return false;
+ return Equals(obj as Partie);
+ }
+
+ public override int GetHashCode()
+ {
+ return Joueur.GetHashCode();
+ }
#endregion
}
}