Files
BUT3ProjetJeuGroupe/fr/iut_fbleau/Avalam/Tower.java

51 lines
1.1 KiB
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package fr.iut_fbleau.Avalam;
/**
* 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 {
private Color color;
private int height;
/** Nouvelle tour de hauteur 1 */
public Tower(Color color) {
this.color = color;
this.height = 1;
}
/** Tour avec couleur et hauteur existantes */
public Tower(Color color, int height) {
this.color = color;
this.height = height;
}
public Color getColor() {
return color;
}
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 sadditionne
*/
public void mergeTower(Tower src) {
this.color = src.color;
this.height = this.height + src.height;
}
@Override
public String toString() {
return color + "(" + height + ")";
}
}