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
Branches
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 { ...@@ -61,10 +61,10 @@ public class FloodGame {
// TODO // TODO
Set<Cell> pendingCells = new HashSet(); Set<Cell> pendingCells = new HashSet();
int Cellcount = 0 ; 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()) ; pendingCells.add(pendingCells.iterator().next()) ;
Cellcount++; Cellcount++;
} }
......
...@@ -29,14 +29,12 @@ public class HumanPlayer implements Player { ...@@ -29,14 +29,12 @@ public class HumanPlayer implements Player {
return this.name ; return this.name ;
} }
// 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.
@Override
public Cell getStartCell() { public Cell getStartCell() {
return null; 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() { public boolean isHuman() {
if (this.name == "player") return true ; if (this.name == "player") return true ;
else return false ; else return false ;
......
...@@ -6,8 +6,10 @@ public interface Player { ...@@ -6,8 +6,10 @@ public interface Player {
void setName(String name) ; //Cette méthode permet de modifier le nom du joueur. 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 String getName(); //Cette méthode permet de récupérer le nom du joueur
//Donnée par le sujet // Cette méthode returner la cellule de départ qui a été attribué au joueur.
Cell getStartCell() ; //Cette méthode retourne la cellule de départ qui a été attribué au joueur static Cell getStartCell() {
return null;
}
//Méthode qui a déjà été fournie //Méthode qui a déjà été fournie
boolean isHuman(); boolean isHuman();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment