Merge pull request 'UTestEquipe' (#26) from UTestEquipe into master
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #26pull/27/head^2
commit
7907ec3c89
@ -1,53 +1,92 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BowlingLib.Model
|
||||
{
|
||||
public class Equipe
|
||||
{
|
||||
private string nom;
|
||||
public ReadOnlyCollection<Joueur> Joueurs
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
private List<Joueur> joueurs;
|
||||
|
||||
public string Nom
|
||||
{
|
||||
get { return nom; }
|
||||
set { nom = value; }
|
||||
}
|
||||
|
||||
public object Id { get; set; }
|
||||
|
||||
private int numero;
|
||||
|
||||
public Equipe(string nom)
|
||||
{
|
||||
this.nom = nom;
|
||||
Joueurs = new ReadOnlyCollection<Joueur>(joueurs);
|
||||
}
|
||||
|
||||
public void AjouterJoueur(Joueur joueur)
|
||||
{
|
||||
joueurs.Add(joueur);
|
||||
}
|
||||
|
||||
public void SupprimerJoueur(Joueur joueur)
|
||||
{
|
||||
joueurs.Remove(joueur);
|
||||
}
|
||||
|
||||
//retourner la liste non modifiable des joueurs de l'équipe
|
||||
public List<Joueur> GetJoueurs()
|
||||
{
|
||||
return joueurs.AsReadOnly().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace BowlingLib.Model
|
||||
{
|
||||
public class Equipe
|
||||
{
|
||||
private string nom;
|
||||
|
||||
public List<Joueur> Joueurs = new List<Joueur>();
|
||||
|
||||
|
||||
public string Nom
|
||||
{
|
||||
get { return nom; }
|
||||
set { nom = value; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Equipe(string nom, params Joueur[] joueurs)
|
||||
{
|
||||
this.nom = nom;
|
||||
AjouterJoueurs(joueurs);
|
||||
// foreach (Joueur nouv in joueurs) AjouterJoueur(nouv);
|
||||
|
||||
}
|
||||
public object Id { get; set; }
|
||||
|
||||
private int numero;
|
||||
|
||||
public Equipe(string nom)
|
||||
{
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
|
||||
public void AjouterJoueurs(params Joueur[] joueurs)
|
||||
{
|
||||
foreach(var j in joueurs)
|
||||
{
|
||||
AjouterJoueur(j);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AjouterJoueur(Joueur joueur)
|
||||
{
|
||||
if(!isExist(joueur))
|
||||
{
|
||||
Joueurs.Add(joueur);
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void SupprimerJoueur(Joueur joueur)
|
||||
{
|
||||
Joueurs.Remove(joueur);
|
||||
}
|
||||
|
||||
//retourner la liste non modifiable des joueurs de l'équipe
|
||||
public long GetJoueurs()
|
||||
{
|
||||
return Joueurs.Count;
|
||||
}
|
||||
|
||||
|
||||
// Fonction permettant de vérifier si un joueur existe déjà dans la liste (l'équipe)
|
||||
public bool isExist(Joueur nouvJoueur)
|
||||
{
|
||||
if (Joueurs.Count > 0) {
|
||||
|
||||
{
|
||||
if (Joueurs.Contains(nouvJoueur)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue