Skip to content
Snippets Groups Projects
Commit 6095ac42 authored by RAKOTOARISOA Andrianinarisaina cy's avatar RAKOTOARISOA Andrianinarisaina cy
Browse files

Tâche 9(12.1) : Création de la classe ComputerPlayer, avec ses attributs...

Tâche 9(12.1) : Création de la classe ComputerPlayer, avec ses attributs (String name) et (Cell startCell) ,sa méthode "public Color play()" et toutes les méthodes à implémenter depuis l'interface Player.
parent 96934805
No related branches found
No related tags found
No related merge requests found
package model;
import javafx.scene.paint.Color;
public class ComputerPlayer implements Player{
String name ;
Cell startCell ;
//Demandée par l'exercice
//Cette méthode renverra une couleur qui correspond à celle choisie par le joueur
public Color play() {
return Player.getStartCell().getColor();
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getName() {
throw new UnsupportedOperationException("Not supported yet.");
}
//Méthode de l'interface Player
public static Cell getStartCell() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isHuman() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
......@@ -61,10 +61,10 @@ public class FloodGame {
// TODO
Set<Cell> pendingCells = new HashSet();
int Cellcount = 0 ;
pendingCells.add(this.player.getStartCell()) ;
pendingCells.add(Player.getStartCell()) ;
while (player.getStartCell().iterator().hasNext()) {
while (Player.getStartCell().iterator().hasNext()) {
pendingCells.add(pendingCells.iterator().next()) ;
Cellcount++;
}
......
......@@ -29,14 +29,12 @@ public class HumanPlayer implements Player {
return this.name ;
}
// Cette méthode retourne la cellule de départ qui a été attribué au joueur.
@Override
// Cette méthode returner la cellule de départ qui a été attribué au joueur.
public Cell getStartCell() {
return null;
}
// Cette méthode détermine si ce joueur est contrôlé par un humain ou par l’ordinateur.
// Cette méthode determine si ce joueur est contrôlé par un humain ou par l’ordinateur.
public boolean isHuman() {
if (this.name == "player") return true ;
else return false ;
......
......@@ -6,8 +6,10 @@ public interface Player {
void setName(String name) ; //Cette méthode permet de modifier le nom du joueur.
String getName(); //Cette méthode permet de récupérer le nom du joueur
//Donnée par le sujet
Cell getStartCell() ; //Cette méthode retourne la cellule de départ qui a été attribué au joueur
// Cette méthode returner la cellule de départ qui a été attribué au joueur.
static Cell getStartCell() {
return null;
}
//Méthode qui a déjà été fournie
boolean isHuman();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment