FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/designPattern/Factory/EnemyShipTesting.java at master · Janani114/Java-Programs · GitHub
Janani114
/
Java-Programs
Public
forked from
divScorp/Java-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
designPattern
/
Factory
/
EnemyShipTesting.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (26 loc) · 821 Bytes
Breadcrumbs
Java-Programs
/
designPattern
/
Factory
/
EnemyShipTesting.java
Copy path
File metadata and controls
32 lines (26 loc) · 821 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
designPattern
.
Factory
;
import
java
.
util
.
Scanner
;
public
class
EnemyShipTesting
{
public
static
void
main
(
String
[]
args
) {
// Create the factory object
EnemyShipFactory
shipFactory
=
new
EnemyShipFactory
();
// Enemy ship object
EnemyShip
theEnemy
=
null
;
Scanner
userInput
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"What type of ship? (U / R / B)"
);
if
(
userInput
.
hasNextLine
()) {
String
typeOfShip
=
userInput
.
nextLine
();
theEnemy
=
shipFactory
.
makeEnemyShip
(
typeOfShip
);
if
(
theEnemy
!=
null
) {
doStuffEnemy
(
theEnemy
);
}
else
System
.
out
.
print
(
"Please enter U, R, or B next time"
);
}
userInput
.
close
();
}
public
static
void
doStuffEnemy
(
EnemyShip
anEnemyShip
) {
anEnemyShip
.
displayEnemyShip
();
anEnemyShip
.
followHeroShip
();
anEnemyShip
.
enemyShipShoots
();
}
}
Back
|
FazBrowse Home
|
New Git URL