Skip to content
Snippets Groups Projects
Commit 884a6b39 authored by HUONG THOMAS's avatar HUONG THOMAS
Browse files

Merge branch 'master' into 'master'

Implementation des methodes de la classe partie

See merge request deleted_user_177013/t4-foc21!21
parents ac20f364 74d6c97e
Branches
No related merge requests found
...@@ -6,16 +6,20 @@ using System.Text; ...@@ -6,16 +6,20 @@ using System.Text;
namespace fichier1.Model namespace fichier1.Model
{ {
public class Partie : IObservable<MainForm> public class Partie : IObservable<Partie>
{ {
private List<string[]> correction; private List<string[]> correction;
private List<string[]> decoupage; private List<string[]> decoupage;
private int motCourant; private int motCourant;
private readonly BddContext context; private readonly BddContext context;
private List<IObserver<Partie>> observers;
public int nbMots;
public Partie(int nbMots, float complexite, BddContext context) public Partie(int nbMots, float complexite, BddContext context)
{ {
this.nbMots = nbMots;
this.context = context; this.context = context;
this.observers = new List<IObserver<Partie>>();
} }
public void genererMots(int nb, float complexite) public void genererMots(int nb, float complexite)
...@@ -41,42 +45,70 @@ namespace fichier1.Model ...@@ -41,42 +45,70 @@ namespace fichier1.Model
public void formaterPropositions() public void formaterPropositions()
{ {
decoupage = new List<string[]>();
for (int i = 0; i < correction.Count; i++)
{
string mot = "";
for (int j = 0; j < correction[i].Length; j++)
{
mot += correction[i][j];
}
string[] m = new string[1];
m[0] = mot;
decoupage.Add(m);
}
} }
public string[] getMot(int nb) public string[] getMot(int nb)
{ {
return null; return decoupage[nb];
} }
public void setMot(int nb, string[] mot) public void setMot(int nb, string[] mot)
{ {
decoupage[nb] = mot;
} }
public int compterPoints() public int compterPoints()
{ {
// TODO:
return 0; return 0;
} }
public string[] getCorrection(int nb) public string[] getCorrection(int nb)
{ {
return null; return correction[nb];
} }
public string[] getMotCourant() public string[] getMotCourant()
{ {
return null; return getMot(motCourant);
} }
public void validerMotCourant(string[] mot) public void validerMotCourant(string[] mot)
{ {
setMot(motCourant, mot);
motCourant++;
if (motCourant < correction.Count)
{
foreach(IObserver<Partie> obs in observers)
{
obs.OnNext(this);
}
}
else
{
foreach (IObserver<Partie> obs in observers)
{
obs.OnCompleted();
}
}
} }
public IDisposable Subscribe(IObserver<MainForm> observer) public IDisposable Subscribe(IObserver<Partie> observer)
{ {
throw new NotImplementedException(); observers.Add(observer);
return null;
} }
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment