-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
32 lines (27 loc) · 913 Bytes
/
Player.java
File metadata and controls
32 lines (27 loc) · 913 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
package decoratordesignpattern;
/**
* This is a character in a video game. Players can be upgraded and have several attributes that need to be defined.
* @author Matt Duggan
*/
public abstract class Player {
protected String name;
protected int intellect;
protected int defense;
protected int attack;
protected String weapon;
protected String armor;
/**
* Prints out the same message for all player types with specific weapon and armor type.
* @return String of the players name, carries a weapon and the armor.
*/
public String toString() {
return this.name + "\nCarries a " + this.weapon + ", and wears a " + this.armor;
}
/**
* The power of the player that gives the player its strength.
* @return The calculated power of players ability.
*/
public double getPower() {
return this.attack * 3 + this.defense + this.intellect / 2;
}
}