-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
61 lines (48 loc) · 964 Bytes
/
Player.java
File metadata and controls
61 lines (48 loc) · 964 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.example;
public class Player {
private int x;
private int y;
private char symbol;
private int previousX;
private int previousY;
public Player(int x, int y, char symbol) {
this.x = x;
this.y = y;
this.symbol = symbol;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public char getSymbol() {
return symbol;
}
public int getPreviousX() {
return previousX;
}
public int getPreviousY() {
return previousY;
}
public void moveDown(){
previousX = x;
previousY = y;
y += 2;
}
public void moveUp(){
previousX = x;
previousY = y;
y -= 2;
}
public void moveLeft(){
previousX = x;
previousY = y;
x -= 2;
}
public void moveRight(){
previousX = x;
previousY = y;
x += 2;
}
}