-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.java
176 lines (131 loc) · 3.8 KB
/
Player.java
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/**
* Player sub class
*
* @Player Class
* @Author - Danny Guan
* @Version - 1
*
*/
public class Player extends Game{
private int PositionRow;
private int PositionCol;
private int PreviousCol;
private int PreviousRow;
private Coordinates PastCoordinates;
private String Name;
/** Player Constructor.
*
* @Param int PositionRow - Y Position of the player
* @Param int PositionCol - X Position of the player
* @Param int PreviousRow - Previous Y Position of the player
* @Param int PreviousCol - Previous X position of the player
* @Param Coordinates PastCoordinates - Stores all the coordinates the player has been
* @Param String Name - Name of the player
*
*/
public Player (int PositionRow, int PositionCol, int PreviousRow, int PreviousCol, Coordinates PastCoordinates, String Name){
this.Name = Name;
this.PositionRow = PositionRow;
this.PositionCol = PositionCol;
this.PreviousCol = PreviousCol;
this.PreviousRow = PreviousRow;
this.PastCoordinates = PastCoordinates;
}
/**
* Returns the name of the player
* @return player name
*/
public String GetName(){
return this.Name;
}
/**
* Returns the player's Y Position
* @return the player's Y Position
*/
public int GetPositionRow(){
return this.PositionRow;
}
/**
* Returns the player's previous Y Position
* @return the player's previous Y Position
*/
public int GetPreviousRow(){
return this.PreviousRow;
}
/**
* Returns the player's X Position
* @return the player's X Position
*/
public int GetPositionCol(){
return this.PositionCol;
}
/**
* Returns the player's previous X Position
* @return the player's previous X Position
*/
public int GetPreviousCol(){
return this.PreviousCol;
}
/**
* Returns the player's past positions
* @return the player's past positions
*/
public void GetCoordinates(){
this.PastCoordinates.PrintCoordinates();
}
/**
* Sets the name of the player
* @param String NewName - Name
* @updates the name of the player
*/
public void SetName(String NewName){
this.Name = NewName;
}
/**
* Sets the Y Position of the player
* @param String PositionRow - X value
* @updates the Y Position of the player
*/
public void SetPositionRow(int PositionRow){
this.PositionRow = PositionRow;
}
/**
* Sets the previous Y Position of the player
* @updates the previous Y Position of the player
*/
public void SetPreviousRow(){
this.PreviousRow = this.PositionRow;
}
/**
* Sets the previous X Position of the player
* @updates the previous X Position of the player
*/
public void SetPreviousCol(){
this.PreviousCol = this.PositionCol;
}
/**
* Sets the X Position of the player
* @param String PositionCol
* @updates the X Position of the player
*/
public void SetPositionCol(int PositionCol){
this.PositionCol = PositionCol;
}
/**
* Adds new coordinates in past coordinates
* @param int YPos - row
* @param int XPos - col
* @updates the past coordinates of the player
*/
public void SetCoordinates(int YPos, int XPos){
int Coordinate = (YPos * 12) + XPos;
this.PastCoordinates.push(Coordinate);
}
/**
* returns all values of the player
* @return player values
*/
public String toString(){
return("Name: " + this.Name + " PositionX: " + this.PositionRow + " PositionY: " + this.PositionCol + " PastPositionX: " + this.PreviousCol + " PastPositionY: " + this.PreviousRow);
}
}