Skip to content
Snippets Groups Projects
Commit c8f49cd5 authored by Thomas BREIL's avatar Thomas BREIL
Browse files

Remove playerClass attribute and add maxHealth super class

parent d8a61ff8
No related branches found
No related tags found
No related merge requests found
......@@ -60,8 +60,6 @@ public class Adventurer extends player {
currenthealthpoints-=1;
}
}
if(currenthealthpoints >= healthpoints) {
currenthealthpoints = healthpoints;
}
super.maxHealth();
}
}
......@@ -56,8 +56,7 @@ public class Archer extends player {
}
}
if (currenthealthpoints >= healthpoints) {
currenthealthpoints = healthpoints;
}
super.maxHealth();
}
}
......@@ -57,9 +57,6 @@ public class Dwarf extends player{
currenthealthpoints+=1;
}
if(currenthealthpoints >= healthpoints) {
currenthealthpoints = healthpoints;
}
super.maxHealth();
}
}
......@@ -7,7 +7,6 @@ import java.util.Random;
public abstract class player {
public String playerName;
public String Avatar_name;
public String Avatar_class;
public Integer money;
......@@ -28,7 +27,6 @@ public abstract class player {
this.playerName = playerName;
Avatar_name = avatar_name;
Avatar_class = this.getClass().getSimpleName().toUpperCase();
this.money = money;
this.inventory = inventory;
this.level = 1;
......@@ -37,10 +35,6 @@ public abstract class player {
this.abilities = new HashMap<>();
}
public String getAvatarClass() {
return this.Avatar_class;
}
public void changeMoney(Integer amount) throws IllegalArgumentException {
......@@ -79,6 +73,12 @@ public abstract class player {
//The rest of the method is implemented in the subclasses
}
protected void maxHealth() {
if (currenthealthpoints >= healthpoints) {
currenthealthpoints = healthpoints;
}
}
public Integer getLevel() {
return this.level;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment