Created
October 9, 2015 21:48
-
-
Save gabicavalcante/397a312397ebc7954c3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package houseofcards; | |
import java.util.ArrayList; | |
/** | |
* Class model to Partie. | |
* @author gabriela cavalcante | |
* @version 09.10 | |
*/ | |
public class Partie { | |
private ArrayList<Joueur> joueurs; | |
ArrayList<Joueur> gagnants; | |
/** | |
* Constructor of class Partie | |
* @param nombreDeJouers number max of player | |
*/ | |
public Partie(int nombreDeJouers) { | |
joueurs = new ArrayList<>(); | |
for (int i = 0; i < nombreDeJouers; i++) { | |
Jeu j = new Jeu(); | |
j.battre(); | |
joueurs.add(new Joueur(j, i)); | |
} | |
} | |
/** | |
* Method to simulate each game movement | |
* @return true or false, to notify when the game is over | |
*/ | |
public boolean mouvement() { | |
Carte carteMax = new Carte("pique", "As"); // carte inférieure | |
gagnants = new ArrayList<>(); | |
for (Joueur joueur : joueurs) { | |
Carte tmp = joueur.tirer(); | |
if (tmp == null) return false; | |
if (tmp.comparer(carteMax) >= 0) { | |
if (tmp.comparer(carteMax) > 0) | |
gagnants.clear(); | |
carteMax = tmp; | |
gagnants.add(joueur); | |
} | |
} | |
for (Joueur j : gagnants) { | |
joueurs.get(joueurs.indexOf(j)).gagner(); | |
} | |
return true; | |
} | |
/** | |
* Method Main | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
Partie p = new Partie(5); | |
while(p.mouvement()); | |
for (Joueur joueur : p.joueurs) { | |
//System.out.println(joueur.getID() + " " + joueur.getNombreDePoints()); | |
System.out.println(joueur.toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment