constructeurs pour classes abstrraites

This commit is contained in:
2025-10-09 11:34:16 +02:00
parent c3c4609d62
commit d4667481c6
4 changed files with 22 additions and 2 deletions

View File

@@ -22,6 +22,14 @@ public abstract class AbstractBoard implements IBoard{
// used as a stack. // used as a stack.
private Deque<AbstractPly> history; private Deque<AbstractPly> history;
// constructeur à appeler dans le constructeur d'un fils concret avec super.
public AbstractBoard(Player p, Deque<AbstractPly> h){
this.currentPlayer = p;
this.history = h;
}
/** /**
* set current player to the other player. * set current player to the other player.

View File

@@ -32,8 +32,11 @@ public abstract class AbstractGame {
// a map from the enum Player to the genuine Player AbstractGamePlayer // a map from the enum Player to the genuine Player AbstractGamePlayer
private EnumMap<Player, AbstractGamePlayer> mapPlayers; private EnumMap<Player, AbstractGamePlayer> mapPlayers;
//NB. pas de constructeur possible on est abstrait, il faut faire une usine abstraite. // constructeur à appeler dans le constructeur d'un fils concret avec super.
public AbstractGame(IBoard b, EnumMap<Player,AbstractGamePlayer> m){
this.currentBoard=b;
this.mapPlayers=m;
}
/** /**
* boucle de contrôle du jeu. * boucle de contrôle du jeu.

View File

@@ -13,6 +13,10 @@ public abstract class AbstractGamePlayer {
// Le joueur réel pourrait avoir besoin de connaître un constructeur de coup? // Le joueur réel pourrait avoir besoin de connaître un constructeur de coup?
// pas pour l'instant. // pas pour l'instant.
// constructeur à appeler dans le constructeur d'un fils concret avec super.
public AbstractGamePlayer(Player p){
this.iAm=p;
}
/** /**
* *

View File

@@ -3,6 +3,11 @@ package fr.iut_fbleau.GameAPI;
public abstract class AbstractPly { public abstract class AbstractPly {
private Player joueur; private Player joueur;
// constructeur à appeler dans le constructeur d'un fils concret avec super.
public AbstractPly(Player j){
this.joueur=j;
}
public Player getPlayer(){ public Player getPlayer(){
return this.joueur; return this.joueur;
} }