forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemyTank.java
More file actions
33 lines (18 loc) · 705 Bytes
/
EnemyTank.java
File metadata and controls
33 lines (18 loc) · 705 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
// EnemyTank implements EnemyAttacker perfectly
// Our job is to make classes with different methods
// from EnemyAttacker to work with the EnemyAttacker interface
import java.util.Random;
public class EnemyTank implements EnemyAttacker{
Random generator = new Random();
public void fireWeapon() {
int attackDamage = generator.nextInt(10) + 1;
System.out.println("Enemy Tank Does " + attackDamage + " Damage");
}
public void driveForward() {
int movement = generator.nextInt(5) + 1;
System.out.println("Enemy Tank moves " + movement + " spaces");
}
public void assignDriver(String driverName) {
System.out.println(driverName + " is driving the tank");
}
}