master
victor perez ngounou 3 years ago
parent d42752c396
commit 03cbcdb149

@ -11,7 +11,7 @@ namespace BowlingLib.Model
/// <summary>
/// Classe Model Equipe
/// </summary>
public class Equipe
public class Equipe:IEquatable<Equipe>
{
#region Propiéters
public string Nom { get; private set; }
@ -52,13 +52,7 @@ namespace BowlingLib.Model
public IEnumerable<Joueur> AjouterJoueurs(params Joueur[] joueurs)
{
List<Joueur> 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);
}
/// <summary>
/// retourner la liste non modifiable des joueurs de l'équipe
/// </summary>
/// <returns></returns>
/// <summary>
/// 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
}

@ -11,7 +11,7 @@ namespace BowlingLib.Model
/// <summary>
/// Classe Model Frame
/// </summary>
public class Frame
public class Frame:IEquatable<Equipe>
{
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();
}
}
}

@ -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
}
}

@ -10,7 +10,7 @@ namespace BowlingLib.Model
/// <summary>
/// Classe Model Partie
/// </summary>
public class Partie
public class Partie:IEquatable<Partie>
{
#region Propriétés
public ReadOnlyCollection<Frame> 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
}
}

Loading…
Cancel
Save