From dde0cf6ee25ed936b0a1b2922192f42da77aecbe Mon Sep 17 00:00:00 2001 From: amary Date: Thu, 16 Oct 2025 11:56:58 +0200 Subject: [PATCH] Classe Tower --- fr/iut_fbleau/Avalam/Color.java | 6 ++++ fr/iut_fbleau/Avalam/Tower.java | 41 ++++++++++++++++++++++++ fr/iut_fbleau/Avalam/temp | 0 fr/iut_fbleau/AvalamTests/TestTower.java | 28 ++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 fr/iut_fbleau/Avalam/Color.java create mode 100644 fr/iut_fbleau/Avalam/Tower.java delete mode 100644 fr/iut_fbleau/Avalam/temp create mode 100644 fr/iut_fbleau/AvalamTests/TestTower.java diff --git a/fr/iut_fbleau/Avalam/Color.java b/fr/iut_fbleau/Avalam/Color.java new file mode 100644 index 0000000..5b91d92 --- /dev/null +++ b/fr/iut_fbleau/Avalam/Color.java @@ -0,0 +1,6 @@ +package fr.iut_fbleau.Avalam ; + +public enum Color{ + RED, + YELLOW +} \ No newline at end of file diff --git a/fr/iut_fbleau/Avalam/Tower.java b/fr/iut_fbleau/Avalam/Tower.java new file mode 100644 index 0000000..0c39254 --- /dev/null +++ b/fr/iut_fbleau/Avalam/Tower.java @@ -0,0 +1,41 @@ +package fr.iut_fbleau.Avalam ; + +/** +* La classe Tower stocke la couleur de son pion haut et la hauteur de la tour. +* +* @version 1.0 +* @author Aurélien +* Date : 16-10-25 ; 16-10-25 +* Licence : +*/ +public class Tower { + //Attributs + private Color color ; + private byte height = 1 ; + + //Constructeur + public Tower(Color color) { + this.color = color ; + } + //Méthodes + public Color getColor() { + return this.color ; + } + public byte getHeight() { + return this.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(); + } + + //Affichage + public String toString() { + return "" ; + } +} diff --git a/fr/iut_fbleau/Avalam/temp b/fr/iut_fbleau/Avalam/temp deleted file mode 100644 index e69de29..0000000 diff --git a/fr/iut_fbleau/AvalamTests/TestTower.java b/fr/iut_fbleau/AvalamTests/TestTower.java new file mode 100644 index 0000000..710edf6 --- /dev/null +++ b/fr/iut_fbleau/AvalamTests/TestTower.java @@ -0,0 +1,28 @@ +package fr.iut_fbleau.AvalamTests ; + +import fr.iut_fbleau.Avalam.Tower ; +import fr.iut_fbleau.Avalam.Color ; + +/** +* La classe TestPion +* +* @version 1.0 +* @author Aurélien +* Date : 16-10-25 ; 16-10-25 +* Licence : +*/ +public class TestTower { + public static void main(String[] args){ + Tower t1 = new Tower(Color.RED); + Tower t2 = new Tower(Color.YELLOW); + + System.out.println("Vérification données :"); + System.out.println("RED = " + t1.getColor()); + System.out.println("1 = " + t1.getHeight()); + + System.out.println("\nVérification empilement :"); + t1.mergeTower(t2); + System.out.println("YELLOW = " + t1.getColor()); + System.out.println("2 = " + t1.getHeight()); + } +} \ No newline at end of file