From 11376d61bc269874bb3c12c7ddeff17d4d76e281 Mon Sep 17 00:00:00 2001 From: josh Date: Wed, 17 Dec 2025 16:35:28 +0100 Subject: [PATCH] retobit terminado --- src/main/java/Character.java | 41 +++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/main/java/Character.java b/src/main/java/Character.java index 6a1b441..4e6745e 100644 --- a/src/main/java/Character.java +++ b/src/main/java/Character.java @@ -1,14 +1,49 @@ -class Character implements Combatant { +abstract class Character implements Combatant { // 🗒️ PROPIEDADES protected String name; protected int health; - // le falta el status + protected Status status; // 🏗️ CONSTRUCTOR protected Character(String name, int health) { this.name = name; this.health = health; - // el status inicial debe ser siempre REGULAR + this.status = Status.REGULAR; } + @Override + public void receiveDamage(int damage){ + this.health -= damage; + if (this.health <= 0) { + this.health = 0; + this.status = Status.DEAD; + } + } + + @Override + public boolean isAlive() { + if (this.health <= 0) { + this.status = Status.DEAD; + System.out.println(this.name + " is dead"); + return false; + } else{ + System.out.println(this.name + " is alive"); + return true; + } + } + + @Override + public int getCurrentHealth(){ + return this.health; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public String getStatus(){ + return this.status.toString() ; + } } \ No newline at end of file