-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
101 lines (90 loc) · 1.82 KB
/
Player.java
File metadata and controls
101 lines (90 loc) · 1.82 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
*
*/
import java.util.ArrayList;
/**
* class: Player
*
* course: ITEC 3150 Spring 2015
*
* written: April 1, 2015
*
* @author Alejandro Guzman
* @version 1.0
*
*
* This is a template for a player. This class extends the character
* class.
*
*
*/
public class Player extends Character {
/**
* An arraylist of items so the player can accumulate items throughout the
* game.
*/
private ArrayList<Item> inventory = new ArrayList<>();
/**
* This constructor follows the super class constructor. It assigns a name
* and makes the healthPoints to 100 and randomly assigns a number between 7
* and 15 to the attackPoints.
*
* @param name
*/
public Player(String name) {
super(name);
}
/**
* This constructor sets the name, health, and attack points. It also sets
* the inventory to this inventory.
*
* @param name
* @param healthPoints
* @param attackPoints
*/
public Player(String name, int healthPoints, int attackPoints,
ArrayList<Item> inventory) {
super(name, healthPoints, attackPoints);
this.inventory = inventory;
// TODO Auto-generated constructor stub
}
/**
* getInventory
*
* @return An ArrayList<Item> representing the player inventory.
*/
public ArrayList<Item> getInventory() {
return inventory;
}
/**
* printInventory
*/
public void printInventory() {
for (Item i : inventory) {
i.printItem();
}
}
/**
* setInventory Set the inventory.
*
* @param inventory
*/
public void setInventory(ArrayList<Item> inventory) {
this.inventory = inventory;
}
/**
* addToInventory
*/
public void addToInventory(Item item) {
inventory.add(item);
}
/**
* toString
*
* @return A string representing of this player.
*/
@Override
public String toString() {
return "Player " + super.toString();
}
}