Exception code

master
Camille TURPIN-ETIENNE 12 months ago
parent 0eae7d04a0
commit e1ea013388

@ -18,20 +18,29 @@
public void AjouterJeton(Jeton jeton)
{
if (NbJetons >= TailleMaximale() )
throw new CodeTailleTableauLesJetonsException();
lesJetons[NbJetons++] = jeton;
}
public void SupprimerDernierJeton()
{
if(NbJetons <= 0)
throw new CodeTailleTableauLesJetonsException();
lesJetons[NbJetons--] = null;
}
public Jeton RecupererJeton(int indice)
{
if(indice < 0 || indice > TailleMaximale())
throw new CodeIndiceInvalideException();
Jeton? jeton = lesJetons[indice];
if (!jeton.HasValue)
throw new Exception();
throw new CodeJetonInvalideException();
return jeton.Value;
}
@ -54,6 +63,8 @@
public IEnumerable<Indicateur> Comparer(Code autreCode)
{
// Mon code est le code correct, l'autre code est celui qui teste
if (autreCode.NbJetons <= TailleMaximale() )
throw new CodeTailleTableauLesJetonsException();
Indicateur[] indicateurs = [];
@ -100,3 +111,5 @@
}
}
}

@ -0,0 +1,19 @@
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) { }
}
}

@ -0,0 +1,19 @@
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,19 @@
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,19 @@
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) { }
}
}

@ -10,7 +10,6 @@
public int TourMaximum { get => 12; }
public int TailleCodeMaximum { get => 4; }
public int NbJoueurs { get => nbJoueurs; }
public int NbJoueursMaximum { get => 2; }

Loading…
Cancel
Save