You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
BowlingScoreApp/Sources/BowlingStub/StubEquipe.cs

85 lines
2.1 KiB

using BowlingLib.Model;
using Business;
using System;
namespace BowlingStub
{
public class StubEquipe : IDataManager<Equipe>
{
private List<Equipe> listEquipes = new List<Equipe>();
public int nbrJ = 10,nbrE = 2;
public StubEquipe()
{
//listEquipes.Add(new Equipe("Equipe 1", new Joueur("Joueur 1"), new Joueur("Joueur 2")));
//listEquipes.Add(new Equipe("Equipe 2", new Joueur("Joueur 3"), new Joueur("Joueur 4")));
//listEquipes.Add(new Equipe("Equipe 3", new Joueur("Joueur 5"), new Joueur("Joueur 6")));
}
public bool Add(Equipe data)
{
if (data != null)
{
listEquipes.Add(data);
return true;
}
return false;
}
public bool Delete(Equipe data)
{
if (data != null)
{
listEquipes.Remove(data);
return true;
}
return false;
}
public void Load()
{
for (int i = 0; i < nbrJ; i++)
{
this.Add(new Equipe("Equipe " + i + 1));
for (int k = 0; k < nbrE; k++)
{
listEquipes.ElementAt(i).AjouterJoueur(new Joueur("Joueur " + i + 1 + "-" + k + 1));
}
}
}
public IEnumerable<Equipe> GetAll()
{
Load();
return listEquipes;
}
//mise à jour d'une équipe
public bool Update(Equipe data)
{
if (data != null)
{
int index = listEquipes.FindIndex(x => x.Id == data.Id);
listEquipes[index] = data;
return true;
}
return false;
}
public Equipe GetDataWithName(string name)
{
throw new NotImplementedException();
}
public IEnumerable<Equipe> GetAllWithDate(DateTime date)
{
throw new NotImplementedException();
}
}
}