1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public class JeuxdeCartes
{
// creation du jeu des 52 cartes
final static String[] couleur = { "Trèfle", "Carreaux", "Coeur", "Pique" };
final static String[] figure = { "2", "3", "4", "5", "6", "7", "8", "9", "10","Valet", "Dame", "Roi", "As"};
public static void DistributionCarte(int NbJeu)
{
for (int i = 0; i < NbJeu; i++)
{
String COULEUR= random(couleur);
String FIGURE=random(figure);
System.out.println("Le joueur a un(e)" + FIGURE + "de" + COULEUR);
}
}
private static String random(String[] table)
{
return table[(int)(Math.random()*table.length)];
}
public static void main(final String args[])
{
int NbJeu = Integer.parseInt(args[0]); // nb joueurs ==> nombres de fois que l'on distribue les cartes
DistributionCarte(NbJeu);
}
} |
Partager