-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangle.java
82 lines (76 loc) · 1.72 KB
/
Rectangle.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
public class Rectangle {
//Instance Variables
private int x,y,w,h,vX,vY, health;
//Paramterized Constructor
public Rectangle(int x, int y, int w, int h, int vX, int vY, int health){
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.vX = vX;
this.vY = vY;
this.health = health;
}
//toString Methods
@Override
public String toString(){
return "Rectangle- \nPosition: (" + x + "," + y + ")\nWidth: " + w + "\nHeight: " + h + "\nVelocityX: " + vX + "\nVelocityY: " + vY + "\nHealth: " + health;
}
//Setters
public void setX(int x){
this.x = x;
}
public void setY(int y){
this.y = y;
}
public void setW(int w){
this.w = w;
}
public void setH(int h){
this.h = h;
}
public void setVX(int vX){
this.vX = vX;
}
public void setVY(int vY){
this.vY = vY;
}
public void setHealth(int health){
this.health = health;
}
//Getters
public int getX(){
return this.x;
}
public int getY(){
return this.y;
}
public int getW(){
return this.w;
}
public int getH(){
return this.h;
}
public int getVX(){
return this.vX;
}
public int getVY(){
return this.vY;
}
public int getHealth(){
return this.health;
}
//Moving Methods
public void moveUp(){
y = y - vY;
}
public void moveDown(){
y = y + vY;
}
public void moveLeft(){
x = x - vX;
}
public void moveRight(){
x = x + vX;
}
}