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.
38 lines
1.1 KiB
38 lines
1.1 KiB
using System;
|
|
using TheGameExtreme.model.card.cardType;
|
|
|
|
namespace TheGameExtreme.model.deck
|
|
{
|
|
public class FractionDeck : Deck
|
|
{
|
|
public FractionDeck()
|
|
{
|
|
Random random = new Random();
|
|
for (int i = 1; i < 100; i ++)
|
|
{
|
|
int entier = random.Next(0, 100);
|
|
int deci = random.Next(0,100);
|
|
decimal d = (decimal)entier + (decimal)deci * 0.001m;
|
|
int numerateur = (int)(d * 1000m);
|
|
int denominateur = 1000;
|
|
int pgcd = PGCD(numerateur, denominateur);
|
|
while (pgcd != 1)
|
|
{
|
|
numerateur = numerateur / pgcd;
|
|
denominateur = denominateur / pgcd;
|
|
pgcd = PGCD(numerateur, denominateur);
|
|
}
|
|
deck.Add(new FractionCard(new Fraction(numerateur, denominateur)));
|
|
}
|
|
}
|
|
|
|
private int PGCD(int a, int b)
|
|
{
|
|
int temp = a % b;
|
|
if (temp == 0)
|
|
return b;
|
|
return PGCD(b, temp);
|
|
}
|
|
}
|
|
}
|