forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemyShip.java
More file actions
50 lines (29 loc) · 1.07 KB
/
EnemyShip.java
File metadata and controls
50 lines (29 loc) · 1.07 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
public abstract class EnemyShip {
private String name;
// Newly defined objects that represent weapon & engine
// These can be changed easily by assigning new parts
// in UFOEnemyShipFactory or UFOBossEnemyShipFactory
ESWeapon weapon;
ESEngine engine;
public String getName() { return name; }
public void setName(String newName) { name = newName; }
abstract void makeShip();
// Because I defined the toString method in engine
// when it is printed the String defined in toString goes
// on the screen
public void followHeroShip(){
System.out.println(getName() + " is following the hero at " + engine );
}
public void displayEnemyShip(){
System.out.println(getName() + " is on the screen");
}
public void enemyShipShoots(){
System.out.println(getName() + " attacks and does " + weapon);
}
// If any EnemyShip object is printed to screen this shows up
public String toString(){
String infoOnShip = "The " + name + " has a top speed of " + engine +
" and an attack power of " + weapon;
return infoOnShip;
}
}