-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTank.java
102 lines (80 loc) · 2.38 KB
/
Tank.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
/** Tank class
* created by Amar Molinas
*
* This class stores date for the individual tank objects for Tank Battle
* by Amar Molinas.
*/
package tankbattle;
import java.awt.Polygon.*;
public class Tank{
//private variables
private String name = ""; //name of tank
private int armor = 0; //tank armor
//tank position variables
/** The GunPower variables correspond the the x and y components of the
* triangle described by the gun barrel and it's angle with respect to
* the center of the turret. When the gun is fired the values of these
* variables are transferred to the xVelocity and yVelocity variables
* so that the shot can be fired independent of the */
private int[] gunPower = new int[2];
/** The angle of the gun barrel, this also controls the amplitude
* of the x an y components of the shot */
private double angle = 0;
/** A two dimensional array defines the positions of the end
* points of the gun. */
private int[][] gun = {{0,0},{0,0}};
/** center point of the turret */
private int[] turret = new int [] {0,0};
private int[][] hull = new int [][] {{0,0,0,0},{0,0,0,0}};
/** default constructor */
public Tank(){
}
/** constructor with arguments */
public Tank(String name, int armor, double angle, int[][] gun,
int[] turret, int[][] hull){
this.name = name;
this.armor = armor;
this.angle = angle;
this.gun = gun;
this.turret = turret;
this.hull = hull;
}
/** accessors */
public String getName(){
return name;
}
public int getArmor(){
return armor;
}
public double getAngle(){
return angle;
}
public int[][] getGun(){
return gun;
}
public int[] getTurret(){
return turret;
}
public int[][] getHull(){
return hull;
}
/** mutators */
public void setName(String name){
this.name = name;
}
public void setArmor(int armor){
this.armor = armor;
}
public void setAngle(double angle){
this.angle = angle;
}
public void setGun(int[][] gun){
this.gun = gun;
}
public void setTurret(int[] turret){
this.turret = turret;
}
public void setHull(int[][] hull){
this.hull = hull;
}
}