Repository navigation
Expand file tree
/
Copy pathAlienShot.java
More file actions
97 lines (80 loc) · 1.82 KB
/
Copy pathAlienShot.java
File metadata and controls
97 lines (80 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
/**
* AlienShot class extends the BattleFieldElement.
* It represents all alienShot elements during the game.
*/
class AlienShot extends BattleFieldElement {
//FIELD
private static final int vDirection=1; //from top to bottom;
protected int moved;
//CONSTRUCTORS
/**
* AlienShot constructor. Specifies the position of the alien shot.
*
* @param v - vertical position of the alien shot
* @param h - horizontal position of the alien shot
*/
public AlienShot(int v, int h){
super(v,h);
this.moved=0;
}
//METHODS
/**
* getXOffset method. Returns the X-offset
*
* @return 0 - returns the X-offset (0)
*/
public int getXOffset() {
return 0;
}
public static int getVdirection() {
return vDirection;
}
/**
* getYOffset method. Returns the Y-offset.
*
* @return Y-offset
*/
public int getYOffset() {
return (BattleField.getRows() - (this.y + 1));
}
/**
* getMoved method. Returns the int moved.
*
* @return moved - the int for the amount moved
*/
public int getMoved() {
return this.moved;
}
/**
* setMoved method. Sets the moved amount of the AlienShot.
*
* @param x - int for amount moved
*/
public void setMoved(int x) {
this.moved = x;
}
/**
* move method. specifies the values of the new position of the AlienShot.
*
* @param v - int vertical position
* @param h - int horizontal position
*/
public void move(int v, int h){
this.y = v;
}
/**
* toString method. overrides the toString method in BattleFieldElement.
*
* @return "S" - string.
*/
@Override
public String toString() {
return "S";
}
@Override
public boolean equals(Object o){
if(o instanceof AlienShot) return false;
AlienShot as = (AlienShot)o;
return (as.x == x)&&(as.y == y)&&(as.vDirection == vDirection)&&(as.moved == moved);
}
}