Jeu jouable avec fin de parti
This commit is contained in:
@@ -1,41 +1,50 @@
|
||||
package fr.iut_fbleau.Avalam ;
|
||||
package fr.iut_fbleau.Avalam;
|
||||
|
||||
/**
|
||||
* La classe <code>Tower</code> stocke la couleur de son pion haut et la hauteur de la tour.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Aurélien
|
||||
*/
|
||||
* Représente une tour dans le jeu Avalam.
|
||||
*
|
||||
* Une tour possède :
|
||||
* - la couleur de son sommet
|
||||
* - sa hauteur (nombre de pions)
|
||||
*/
|
||||
public class Tower {
|
||||
//Attributs
|
||||
private Color color ;
|
||||
private byte height = 1 ;
|
||||
|
||||
//Constructeur
|
||||
public Tower(Color color) {
|
||||
this.color = color ;
|
||||
}
|
||||
private Color color;
|
||||
private int height;
|
||||
|
||||
//Méthodes
|
||||
public Color getColor() {
|
||||
return this.color ;
|
||||
}
|
||||
/** Nouvelle tour de hauteur 1 */
|
||||
public Tower(Color color) {
|
||||
this.color = color;
|
||||
this.height = 1;
|
||||
}
|
||||
|
||||
public byte getHeight() {
|
||||
return this.height ;
|
||||
}
|
||||
/** Tour avec couleur et hauteur existantes */
|
||||
public Tower(Color color, int height) {
|
||||
this.color = color;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode qui empile une autre tour sur l'objet sur lequel le méthode est appelée.
|
||||
* Aucune vérification de hauteur n'est effectuée.
|
||||
*/
|
||||
public void mergeTower(Tower tower) {
|
||||
this.color = tower.getColor();
|
||||
this.height += tower.getHeight();
|
||||
}
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "" ;
|
||||
}
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fusionne this (destination) avec src (source).
|
||||
* La source monte sur la destination →
|
||||
* - la couleur du sommet devient celle de src
|
||||
* - la hauteur s’additionne
|
||||
*/
|
||||
public void mergeTower(Tower src) {
|
||||
this.color = src.color;
|
||||
this.height = this.height + src.height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return color + "(" + height + ")";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user