using System;
using TheGameExtreme.model.card.cardType;
namespace TheGameExtreme.model.deck
{
public class FractionDeck : Deck
{
/**
* Fonction permettant de créer un jeu de carte pour jouer avec les fractions
*/
public FractionDeck()
{
Random random = new Random();
for (int i = 1; i < 100; i ++)
{
int numerateur = random.Next(1, 100);
int denominateur = random.Next(1, 100);
int pgcd = PGCD(numerateur, denominateur);
while (pgcd != 1)
{
numerateur /= pgcd;
denominateur /= pgcd;
pgcd = PGCD(numerateur, denominateur);
}
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(numerateur, denominateur)));
}
}
/**
* Fonction permettant de retourner le plus grand diviseur commun à deux nombres
* Premier nombre
* Deuxième nombre
* Plus grand diviseur commun
*/
private int PGCD(int a, int b)
{
int temp = a % b;
if (temp == 0)
return b;
return PGCD(b, temp);
}
}
}