Exception de la Class code
continuous-integration/drone/push Build is passing Details

master
parent 9d5686ad97
commit e0ad921724

@ -18,8 +18,8 @@
public void AjouterJeton(Jeton jeton) public void AjouterJeton(Jeton jeton)
{ {
if (NbJetons >= TailleMaximale() ) if (EstComplet())
throw new CodeTailleTableauLesJetonsException(); throw new CodeTailleTableauLesJetonsCompletException();
lesJetons[NbJetons++] = jeton; lesJetons[NbJetons++] = jeton;
} }
@ -27,7 +27,7 @@
public void SupprimerDernierJeton() public void SupprimerDernierJeton()
{ {
if(NbJetons <= 0) if(NbJetons <= 0)
throw new CodeTailleTableauLesJetonsException(); throw new CodeTableauLesJetonsVideException();
lesJetons[NbJetons--] = null; lesJetons[NbJetons--] = null;
} }
@ -35,12 +35,12 @@
public Jeton RecupererJeton(int indice) public Jeton RecupererJeton(int indice)
{ {
if(indice < 0 || indice > TailleMaximale()) if(indice < 0 || indice > TailleMaximale())
throw new CodeIndiceInvalideException(); throw new CodeIndiceHorsDePortéeException();
Jeton? jeton = lesJetons[indice]; Jeton? jeton = lesJetons[indice];
if (!jeton.HasValue) if (!jeton.HasValue)
throw new CodeJetonInvalideException(); throw new CodeJetonNullException();
return jeton.Value; return jeton.Value;
} }
@ -63,8 +63,8 @@
public IEnumerable<Indicateur> Comparer(Code autreCode) public IEnumerable<Indicateur> Comparer(Code autreCode)
{ {
// Mon code est le code correct, l'autre code est celui qui teste // Mon code est le code correct, l'autre code est celui qui teste
if (autreCode.NbJetons <= TailleMaximale() ) if (!autreCode.EstComplet())
throw new CodeTailleTableauLesJetonsException(); throw new CodeTailleTableauLesJetonsCompletException();
Indicateur[] indicateurs = []; Indicateur[] indicateurs = [];

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeIndiceHorsDePortéeException : Exception
{
public CodeIndiceHorsDePortéeException() : base("L'indice pointe en dehors du tableau")
{ }
}
}

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeIndiceInvalideException : Exception
{
public CodeIndiceInvalideException() { }
public CodeIndiceInvalideException(string message)
: base(message) { }
public CodeIndiceInvalideException(string message, Exception inner)
: base(message, inner) { }
}
}

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
internal class CodeJetonInvalideException : Exception
{
public CodeJetonInvalideException() { }
public CodeJetonInvalideException(string message)
: base(message) { }
public CodeJetonInvalideException(string message, Exception inner)
: base(message, inner) { }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
internal class CodeJetonNullException : Exception
{
public CodeJetonNullException() : base("le jeton est null")
{ }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeTableauLesJetonsIncompletException : Exception
{
public CodeTableauLesJetonsIncompletException() : base("Le tableau des jetons est incomplet")
{ }
}
}

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeTableauLesJetonsVideException : Exception
{
public CodeTableauLesJetonsVideException() : base("Le tableau des jetons est vide")
{ }
}
}

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeTailleTableauException : Exception
{
public CodeTailleTableauException() { }
public CodeTailleTableauException(string message)
: base(message) { }
public CodeTailleTableauException(string message, Exception inner)
: base(message, inner) { }
}
}

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeTailleTableauLesJetonsCompletException : Exception
{
public CodeTailleTableauLesJetonsCompletException() : base("Le tableau des jetons est plein")
{ }
}
}

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoreLibrary
{
public class CodeTailleTableauLesJetonsException : Exception
{
public CodeTailleTableauLesJetonsException() { }
public CodeTailleTableauLesJetonsException(string message)
: base(message) { }
public CodeTailleTableauLesJetonsException(string message, Exception inner)
: base(message, inner) { }
}
}

@ -53,12 +53,12 @@
{ {
if (code.TailleMaximale() != tailleCode) if (code.TailleMaximale() != tailleCode)
{ {
throw new CodeTailleMaximaleException(); throw new PlateauTailleCodeException();
} }
if (!code.EstComplet()) if (!code.EstComplet())
{ {
throw new CodeIncompletException(); throw new PlateauCodeIncompletException();
} }
indicateurs[Tour - 1] = codeSecret.Comparer(code); indicateurs[Tour - 1] = codeSecret.Comparer(code);

Loading…
Cancel
Save