-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathCreature.java
More file actions
36 lines (30 loc) · 808 Bytes
/
Creature.java
File metadata and controls
36 lines (30 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class Creature {
private String name;
private int attackValue;
private int hitpoints;
public Creature(String name, int attackValue, int hitpoints) {
this.name = name;
this.attackValue = attackValue;
this.hitpoints = hitpoints;
}
public String getName() {
return name;
}
public int getAttackValue() {
return attackValue;
}
public int getHitpoints() {
return hitpoints;
}
public void attackCreature(Creature creature) {
creature.hitpoints -= this.attackValue;
System.out.println(
this.name
+ " greift "
+ creature.name
+ " an und erzielt "
+ this.attackValue
+ " Schaden");
System.out.println(creature.name + " hat noch " + creature.hitpoints + " Lebenspunkte");
}
}