Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Utilizando Java 17 -->
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
Expand Down
44 changes: 41 additions & 3 deletions src/main/java/Character.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
class Character implements Combatant {
//Errores detectados
//Falta de implementacion de metodos de la interface
//Falta de modificador de clase (abstract)
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 = this.health - damage;
if (this.health <= 0) {
this.health = 0;
this.status = Status.DEAD;
}
}

@Override
public boolean isAlive() {
return this.health > 0;
/* OR
if ( this.health > 0 ) {
return true;
} else {
return false;
}
*/
}

@Override
public int getCurrentHealth() {
return this.health;
}

@Override
public String getName() {
return this.name;
}

@Override
public String getStatus() {
return this.status.toString();
}
}