Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
battleships
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bradley.vernon
battleships
Commits
7ca9d1b4
Commit
7ca9d1b4
authored
May 16, 2019
by
Darth Vernon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GUI improvements
parent
a1df916a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
542 additions
and
35 deletions
+542
-35
BSGUI.fxml
src/BSGUI.fxml
+269
-10
BSMain.java
src/BSMain.java
+252
-5
BattleClass.java
src/BattleClass.java
+16
-18
ComputerInput.java
src/ComputerInput.java
+2
-0
ShipClass.java
src/ShipClass.java
+3
-2
No files found.
src/BSGUI.fxml
View file @
7ca9d1b4
This diff is collapsed.
Click to expand it.
src/BSMain.java
View file @
7ca9d1b4
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
import
java.util.ArrayList
;
import
javax.xml.bind.annotation.XmlElementDecl.GLOBAL
;
import
javafx.application.Application
;
import
javafx.application.Application
;
import
javafx.collections.FXCollections
;
import
javafx.collections.FXCollections
;
import
javafx.collections.ObservableList
;
import
javafx.collections.ObservableList
;
...
@@ -10,6 +14,7 @@ import javafx.fxml.FXML;
...
@@ -10,6 +14,7 @@ import javafx.fxml.FXML;
import
javafx.fxml.FXMLLoader
;
import
javafx.fxml.FXMLLoader
;
import
javafx.scene.Parent
;
import
javafx.scene.Parent
;
import
javafx.scene.Scene
;
import
javafx.scene.Scene
;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.ChoiceBox
;
import
javafx.scene.control.ChoiceBox
;
import
javafx.scene.control.Label
;
import
javafx.scene.control.Label
;
...
@@ -20,6 +25,7 @@ import javafx.stage.Stage;
...
@@ -20,6 +25,7 @@ import javafx.stage.Stage;
public
class
BSMain
extends
Application
{
public
class
BSMain
extends
Application
{
@FXML
public
ChoiceBox
<
String
>
DPx
;
@FXML
public
ChoiceBox
<
String
>
DPx
;
@FXML
public
ChoiceBox
<
String
>
DPy
;
@FXML
public
ChoiceBox
<
String
>
DPy
;
@FXML
public
ChoiceBox
<
String
>
shipSelection
;
@FXML
public
ChoiceBox
<
String
>
shipSelection
;
...
@@ -34,6 +40,237 @@ public class BSMain extends Application{
...
@@ -34,6 +40,237 @@ public class BSMain extends Application{
@FXML
public
Label
admiral
;
@FXML
public
Label
admiral
;
@FXML
public
Label
status
;
@FXML
public
Label
status
;
@FXML
public
Label
p0A
;
@FXML
public
Label
p1A
;
@FXML
public
Label
p2A
;
@FXML
public
Label
p3A
;
@FXML
public
Label
p4A
;
@FXML
public
Label
p5A
;
@FXML
public
Label
p6A
;
@FXML
public
Label
p7A
;
@FXML
public
Label
p8A
;
@FXML
public
Label
p9A
;
@FXML
public
Label
c0A
;
@FXML
public
Label
c1A
;
@FXML
public
Label
c2A
;
@FXML
public
Label
c3A
;
@FXML
public
Label
c4A
;
@FXML
public
Label
c5A
;
@FXML
public
Label
c6A
;
@FXML
public
Label
c7A
;
@FXML
public
Label
c8A
;
@FXML
public
Label
c9A
;
@FXML
public
Label
p0B
;
@FXML
public
Label
p1B
;
@FXML
public
Label
p2B
;
@FXML
public
Label
p3B
;
@FXML
public
Label
p4B
;
@FXML
public
Label
p5B
;
@FXML
public
Label
p6B
;
@FXML
public
Label
p7B
;
@FXML
public
Label
p8B
;
@FXML
public
Label
p9B
;
@FXML
public
Label
c0B
;
@FXML
public
Label
c1B
;
@FXML
public
Label
c2B
;
@FXML
public
Label
c3B
;
@FXML
public
Label
c4B
;
@FXML
public
Label
c5B
;
@FXML
public
Label
c6B
;
@FXML
public
Label
c7B
;
@FXML
public
Label
c8B
;
@FXML
public
Label
c9B
;
@FXML
public
Label
p0C
;
@FXML
public
Label
p1C
;
@FXML
public
Label
p2C
;
@FXML
public
Label
p3C
;
@FXML
public
Label
p4C
;
@FXML
public
Label
p5C
;
@FXML
public
Label
p6C
;
@FXML
public
Label
p7C
;
@FXML
public
Label
p8C
;
@FXML
public
Label
p9C
;
@FXML
public
Label
c0C
;
@FXML
public
Label
c1C
;
@FXML
public
Label
c2C
;
@FXML
public
Label
c3C
;
@FXML
public
Label
c4C
;
@FXML
public
Label
c5C
;
@FXML
public
Label
c6C
;
@FXML
public
Label
c7C
;
@FXML
public
Label
c8C
;
@FXML
public
Label
c9C
;
@FXML
public
Label
p0D
;
@FXML
public
Label
p1D
;
@FXML
public
Label
p2D
;
@FXML
public
Label
p3D
;
@FXML
public
Label
p4D
;
@FXML
public
Label
p5D
;
@FXML
public
Label
p6D
;
@FXML
public
Label
p7D
;
@FXML
public
Label
p8D
;
@FXML
public
Label
p9D
;
@FXML
public
Label
c0D
;
@FXML
public
Label
c1D
;
@FXML
public
Label
c2D
;
@FXML
public
Label
c3D
;
@FXML
public
Label
c4D
;
@FXML
public
Label
c5D
;
@FXML
public
Label
c6D
;
@FXML
public
Label
c7D
;
@FXML
public
Label
c8D
;
@FXML
public
Label
c9D
;
@FXML
public
Label
p0F
;
@FXML
public
Label
p1F
;
@FXML
public
Label
p2F
;
@FXML
public
Label
p3F
;
@FXML
public
Label
p4F
;
@FXML
public
Label
p5F
;
@FXML
public
Label
p6F
;
@FXML
public
Label
p7F
;
@FXML
public
Label
p8F
;
@FXML
public
Label
p9F
;
@FXML
public
Label
c0F
;
@FXML
public
Label
c1F
;
@FXML
public
Label
c2F
;
@FXML
public
Label
c3F
;
@FXML
public
Label
c4F
;
@FXML
public
Label
c5F
;
@FXML
public
Label
c6F
;
@FXML
public
Label
c7F
;
@FXML
public
Label
c8F
;
@FXML
public
Label
c9F
;
@FXML
public
Label
p0E
;
@FXML
public
Label
p1E
;
@FXML
public
Label
p2E
;
@FXML
public
Label
p3E
;
@FXML
public
Label
p4E
;
@FXML
public
Label
p5E
;
@FXML
public
Label
p6E
;
@FXML
public
Label
p7E
;
@FXML
public
Label
p8E
;
@FXML
public
Label
p9E
;
@FXML
public
Label
c0E
;
@FXML
public
Label
c1E
;
@FXML
public
Label
c2E
;
@FXML
public
Label
c3E
;
@FXML
public
Label
c4E
;
@FXML
public
Label
c5E
;
@FXML
public
Label
c6E
;
@FXML
public
Label
c7E
;
@FXML
public
Label
c8E
;
@FXML
public
Label
c9E
;
@FXML
public
Label
p0G
;
@FXML
public
Label
p1G
;
@FXML
public
Label
p2G
;
@FXML
public
Label
p3G
;
@FXML
public
Label
p4G
;
@FXML
public
Label
p5G
;
@FXML
public
Label
p6G
;
@FXML
public
Label
p7G
;
@FXML
public
Label
p8G
;
@FXML
public
Label
p9G
;
@FXML
public
Label
c0G
;
@FXML
public
Label
c1G
;
@FXML
public
Label
c2G
;
@FXML
public
Label
c3G
;
@FXML
public
Label
c4G
;
@FXML
public
Label
c5G
;
@FXML
public
Label
c6G
;
@FXML
public
Label
c7G
;
@FXML
public
Label
c8G
;
@FXML
public
Label
c9G
;
@FXML
public
Label
p0H
;
@FXML
public
Label
p1H
;
@FXML
public
Label
p2H
;
@FXML
public
Label
p3H
;
@FXML
public
Label
p4H
;
@FXML
public
Label
p5H
;
@FXML
public
Label
p6H
;
@FXML
public
Label
p7H
;
@FXML
public
Label
p8H
;
@FXML
public
Label
p9H
;
@FXML
public
Label
c0H
;
@FXML
public
Label
c1H
;
@FXML
public
Label
c2H
;
@FXML
public
Label
c3H
;
@FXML
public
Label
c4H
;
@FXML
public
Label
c5H
;
@FXML
public
Label
c6H
;
@FXML
public
Label
c7H
;
@FXML
public
Label
c8H
;
@FXML
public
Label
c9H
;
@FXML
public
Label
p0I
;
@FXML
public
Label
p1I
;
@FXML
public
Label
p2I
;
@FXML
public
Label
p3I
;
@FXML
public
Label
p4I
;
@FXML
public
Label
p5I
;
@FXML
public
Label
p6I
;
@FXML
public
Label
p7I
;
@FXML
public
Label
p8I
;
@FXML
public
Label
p9I
;
@FXML
public
Label
c0I
;
@FXML
public
Label
c1I
;
@FXML
public
Label
c2I
;
@FXML
public
Label
c3I
;
@FXML
public
Label
c4I
;
@FXML
public
Label
c5I
;
@FXML
public
Label
c6I
;
@FXML
public
Label
c7I
;
@FXML
public
Label
c8I
;
@FXML
public
Label
c9I
;
@FXML
public
Label
p0J
;
@FXML
public
Label
p1J
;
@FXML
public
Label
p2J
;
@FXML
public
Label
p3J
;
@FXML
public
Label
p4J
;
@FXML
public
Label
p5J
;
@FXML
public
Label
p6J
;
@FXML
public
Label
p7J
;
@FXML
public
Label
p8J
;
@FXML
public
Label
p9J
;
@FXML
public
Label
c0J
;
@FXML
public
Label
c1J
;
@FXML
public
Label
c2J
;
@FXML
public
Label
c3J
;
@FXML
public
Label
c4J
;
@FXML
public
Label
c5J
;
@FXML
public
Label
c6J
;
@FXML
public
Label
c7J
;
@FXML
public
Label
c8J
;
@FXML
public
Label
c9J
;
@FXML
Label
computerLabels
[]
=
{
c0A
,
c0B
,
c0C
,
c0D
,
c0E
,
c0F
,
c0G
,
c0H
,
c0I
,
c0J
,
c1A
,
c1B
,
c1C
,
c1D
,
c1E
,
c1F
,
c1G
,
c1H
,
c1I
,
c1J
,
c2A
,
c2B
,
c2C
,
c2D
,
c2E
,
c2F
,
c2G
,
c2H
,
c2I
,
c2J
,
c3A
,
c3B
,
c3C
,
c3D
,
c3E
,
c3F
,
c3G
,
c3H
,
c3I
,
c3J
,
c4A
,
c4B
,
c4C
,
c4D
,
c4E
,
c4F
,
c4G
,
c4H
,
c4I
,
c4J
,
c5A
,
c5B
,
c5C
,
c5D
,
c5E
,
c5F
,
c5G
,
c5H
,
c5I
,
c5J
,
c6A
,
c6B
,
c6C
,
c6D
,
c6E
,
c6F
,
c6G
,
c6H
,
c6I
,
c6J
,
c7A
,
c7B
,
c7C
,
c7D
,
c7E
,
c7F
,
c7G
,
c7H
,
c7I
,
c7J
,
c8A
,
c8B
,
c8C
,
c8D
,
c8E
,
c8F
,
c8G
,
c8H
,
c8I
,
c8J
,
c9A
,
c9B
,
c9C
,
c9D
,
c9E
,
c9F
,
c9G
,
c9H
,
c9I
,
c9J
};
@FXML
Label
playerLabels
[]
=
{
p0A
,
p0B
,
p0C
,
p0D
,
p0E
,
p0F
,
p0G
,
p0H
,
p0I
,
p0J
,
p1A
,
p1B
,
p1C
,
p1D
,
p1E
,
p1F
,
p1G
,
p1H
,
p1I
,
p1J
,
p2A
,
p2B
,
p2C
,
p2D
,
p2E
,
p2F
,
p2G
,
p2H
,
p2I
,
p2J
,
p3A
,
p3B
,
p3C
,
p3D
,
p3E
,
p3F
,
p3G
,
p3H
,
p3I
,
p3J
,
p4A
,
p4B
,
p4C
,
p4D
,
p4E
,
p4F
,
p4G
,
p4H
,
p4I
,
p4J
,
p5A
,
p5B
,
p5C
,
p5D
,
p5E
,
p5F
,
p5G
,
p5H
,
p5I
,
p5J
,
p6A
,
p6B
,
p6C
,
p6D
,
p6E
,
p6F
,
p6G
,
p6H
,
p6I
,
p6J
,
p7A
,
p7B
,
p7C
,
p7D
,
p7E
,
p7F
,
p7G
,
p7H
,
p7I
,
p7J
,
p8A
,
p8B
,
p8C
,
p8D
,
p8E
,
p8F
,
p8G
,
p8H
,
p8I
,
p8J
,
p9A
,
p9B
,
p9C
,
p9D
,
p9E
,
p9F
,
p9G
,
p9H
,
p9I
,
p9J
};
ObservableList
<
String
>
numbrz
=
FXCollections
.
observableArrayList
(
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
);
ObservableList
<
String
>
numbrz
=
FXCollections
.
observableArrayList
(
"0"
,
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
);
ObservableList
<
String
>
ltrz
=
FXCollections
.
observableArrayList
(
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
);
ObservableList
<
String
>
ltrz
=
FXCollections
.
observableArrayList
(
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
);
static
ObservableList
<
String
>
ships
=
FXCollections
.
observableArrayList
(
"Aircraft"
,
"BattleShip"
,
"BattleShip Two"
,
"Destroyer One"
,
"Destroyer Two"
,
"Patrol Boat One"
,
static
ObservableList
<
String
>
ships
=
FXCollections
.
observableArrayList
(
"Aircraft"
,
"BattleShip"
,
"BattleShip Two"
,
"Destroyer One"
,
"Destroyer Two"
,
"Patrol Boat One"
,
...
@@ -63,6 +300,7 @@ public class BSMain extends Application{
...
@@ -63,6 +300,7 @@ public class BSMain extends Application{
Scene
scene
=
new
Scene
(
root
,
300
,
275
);
Scene
scene
=
new
Scene
(
root
,
300
,
275
);
scene
.
setRoot
(
root
);
scene
.
setRoot
(
root
);
arg0
.
setTitle
(
"Battleships"
);
arg0
.
setTitle
(
"Battleships"
);
arg0
.
setScene
(
scene
);
arg0
.
setScene
(
scene
);
...
@@ -80,7 +318,7 @@ public class BSMain extends Application{
...
@@ -80,7 +318,7 @@ public class BSMain extends Application{
DPy
.
getItems
().
addAll
(
ltrz
);
DPy
.
getItems
().
addAll
(
ltrz
);
shipSelection
.
getItems
().
addAll
(
ships
);
shipSelection
.
getItems
().
addAll
(
ships
);
DPx
.
getSelectionModel
().
selectedItemProperty
().
addListener
((
ObservableValue
,
oldValue
,
newValue
)
->
{
DPx
.
getSelectionModel
().
selectedItemProperty
().
addListener
((
ObservableValue
,
oldValue
,
newValue
)
->
{
x
=(
newValue
.
toString
());
x
=(
newValue
.
toString
());
...
@@ -103,8 +341,11 @@ public class BSMain extends Application{
...
@@ -103,8 +341,11 @@ public class BSMain extends Application{
if
(
stage0
)
{
if
(
stage0
)
{
playerS
.
ShipPlacer
(
playerS
,
ship
,
x
,
y
);
admiral
.
setText
(
"Admiral Nutsey: Ship placed at "
+
x
+
y
);
admiral
.
setText
(
"Admiral Nutsey: Ship placed at "
+
(
playerS
.
ShipPlacer
(
playerS
,
ship
,
x
,
y
).
toString
())
);
if
(!
playerG
.
MoveValidCheck
(
playerG
,
playerS
.
moves
,
playerS
,
ship
)){
if
(!
playerG
.
MoveValidCheck
(
playerG
,
playerS
.
moves
,
playerS
,
ship
)){
admiral
.
setText
(
"Admiral Nutsey: Space occupied"
);
admiral
.
setText
(
"Admiral Nutsey: Space occupied"
);
...
@@ -138,8 +379,13 @@ public class BSMain extends Application{
...
@@ -138,8 +379,13 @@ public class BSMain extends Application{
String
CmptrMove
=
(
String
)
ComputerInput
.
CoOrdRandomiser
().
get
(
0
)
String
CmptrMove
=
(
String
)
ComputerInput
.
CoOrdRandomiser
().
get
(
0
)
+
(
String
)
ComputerInput
.
CoOrdRandomiser
().
get
(
1
);
+
(
String
)
ComputerInput
.
CoOrdRandomiser
().
get
(
1
);
playerB
.
fire
(
computerS
,
HmnMove
);
if
(
playerB
.
fire
(
computerS
,
HmnMove
))
{
computerB
.
fire
(
playerS
,
CmptrMove
);
admiral
.
setText
(
BattleClass
.
ShipCheck
(
HmnMove
,
computerS
));
}
if
(
computerB
.
fire
(
playerS
,
CmptrMove
))
{
admiral
.
setText
(
BattleClass
.
ShipCheck
(
CmptrMove
,
playerS
));
}
status
.
setText
(
"Computer status: "
+
computerS
.
allMoves
.
size
()
+
" Player Status: "
+
playerS
.
allMoves
.
size
());
status
.
setText
(
"Computer status: "
+
computerS
.
allMoves
.
size
()
+
" Player Status: "
+
playerS
.
allMoves
.
size
());
}
}
...
@@ -175,6 +421,7 @@ public class BSMain extends Application{
...
@@ -175,6 +421,7 @@ public class BSMain extends Application{
ComputerInput
.
cmptrMoveGen
();
ComputerInput
.
cmptrMoveGen
();
launch
(
args
);
launch
(
args
);
...
...
src/BattleClass.java
View file @
7ca9d1b4
...
@@ -5,37 +5,34 @@ public class BattleClass {
...
@@ -5,37 +5,34 @@ public class BattleClass {
public
void
fire
(
ShipClass
opponent
,
String
Coordinates
)
{
public
Boolean
fire
(
ShipClass
opponent
,
String
Coordinates
)
{
Boolean
hit
=
false
;
if
(
opponent
.
allMoves
.
contains
(
Coordinates
))
{
if
(
opponent
.
allMoves
.
contains
(
Coordinates
))
{
System
.
out
.
println
(
"Hit on "
+
Coordinates
);
System
.
out
.
println
(
"Hit on "
+
Coordinates
);
opponent
.
allMoves
.
remove
(
Coordinates
);
opponent
.
allMoves
.
remove
(
Coordinates
);
ShipCheck
(
Coordinates
,
opponent
);
hit
=
true
;
}
else
{
System
.
out
.
println
(
"Miss at "
+
Coordinates
);
}
}
return
hit
;
}
}
public
void
ShipCheck
(
String
coordinates
,
ShipClass
opponent
)
{
public
static
String
ShipCheck
(
String
coordinates
,
ShipClass
opponent
)
{
String
response
=
"Hit on "
+
coordinates
;
if
(
opponent
.
aC
.
contains
(
coordinates
))
{
if
(
opponent
.
aC
.
contains
(
coordinates
))
{
opponent
.
aC
.
remove
(
coordinates
);
opponent
.
aC
.
remove
(
coordinates
);
if
(
opponent
.
aC
.
isEmpty
())
{
if
(
opponent
.
aC
.
isEmpty
())
{
System
.
out
.
println
(
"Aircarft one is sunk!"
);
response
=
(
"Aircarft one is sunk!"
);
}
}
}
}
...
@@ -44,7 +41,7 @@ public class BattleClass {
...
@@ -44,7 +41,7 @@ public class BattleClass {
opponent
.
bS
.
remove
(
coordinates
);
opponent
.
bS
.
remove
(
coordinates
);
if
(
opponent
.
bS
.
isEmpty
())
{
if
(
opponent
.
bS
.
isEmpty
())
{
System
.
out
.
println
(
"BattleShip one is sunk!"
);
response
=
(
"BattleShip one is sunk!"
);
}
}
}
}
...
@@ -53,7 +50,7 @@ public class BattleClass {
...
@@ -53,7 +50,7 @@ public class BattleClass {
opponent
.
bS2
.
remove
(
coordinates
);
opponent
.
bS2
.
remove
(
coordinates
);
if
(
opponent
.
bS2
.
isEmpty
())
{
if
(
opponent
.
bS2
.
isEmpty
())
{
System
.
out
.
println
(
"Battleship two is sunk!"
);
response
=
(
"Battleship two is sunk!"
);
}
}
}
}
...
@@ -62,7 +59,7 @@ public class BattleClass {
...
@@ -62,7 +59,7 @@ public class BattleClass {
opponent
.
dS
.
remove
(
coordinates
);
opponent
.
dS
.
remove
(
coordinates
);
if
(
opponent
.
dS
.
isEmpty
())
{
if
(
opponent
.
dS
.
isEmpty
())
{
System
.
out
.
println
(
"Destroyer one is sunk!"
);
response
=
(
"Destroyer one is sunk!"
);
}
}
}
}
...
@@ -71,7 +68,7 @@ public class BattleClass {
...
@@ -71,7 +68,7 @@ public class BattleClass {
opponent
.
dS2
.
remove
(
coordinates
);
opponent
.
dS2
.
remove
(
coordinates
);
if
(
opponent
.
dS2
.
isEmpty
())
{
if
(
opponent
.
dS2
.
isEmpty
())
{
System
.
out
.
println
(
"Destroyer two is sunk!"
);
response
=
(
"Destroyer two is sunk!"
);
}
}
}
}
...
@@ -80,7 +77,7 @@ public class BattleClass {
...
@@ -80,7 +77,7 @@ public class BattleClass {
opponent
.
pB
.
remove
(
coordinates
);
opponent
.
pB
.
remove
(
coordinates
);
if
(
opponent
.
pB
.
isEmpty
())
{
if
(
opponent
.
pB
.
isEmpty
())
{
System
.
out
.
println
(
"Patrol boat one is sunk!"
);
response
=
(
"Patrol boat one is sunk!"
);
}
}
}
}
...
@@ -89,7 +86,7 @@ public class BattleClass {
...
@@ -89,7 +86,7 @@ public class BattleClass {
opponent
.
pB2
.
remove
(
coordinates
);
opponent
.
pB2
.
remove
(
coordinates
);
if
(
opponent
.
pB2
.
isEmpty
())
{
if
(
opponent
.
pB2
.
isEmpty
())
{
System
.
out
.
println
(
"Patrol boat two is sunk!"
);
response
=
(
"Patrol boat two is sunk!"
);
}
}
}
}
...
@@ -98,9 +95,10 @@ public class BattleClass {
...
@@ -98,9 +95,10 @@ public class BattleClass {
opponent
.
pB3
.
remove
(
coordinates
);
opponent
.
pB3
.
remove
(
coordinates
);
if
(
opponent
.
pB3
.
isEmpty
())
{
if
(
opponent
.
pB3
.
isEmpty
())
{
System
.
out
.
println
(
"Patrol boat three is sunk!"
);
response
=
(
"Patrol boat three is sunk!"
);
}
}
}
}
return
response
;
}
}
...
...
src/ComputerInput.java
View file @
7ca9d1b4
...
@@ -27,6 +27,8 @@ public class ComputerInput {
...
@@ -27,6 +27,8 @@ public class ComputerInput {
String
x
=
(
String
)
CoOrdRandomiser
().
get
(
0
);
String
x
=
(
String
)
CoOrdRandomiser
().
get
(
0
);
String
y
=
(
String
)
CoOrdRandomiser
().
get
(
1
);
String
y
=
(
String
)
CoOrdRandomiser
().
get
(
1
);
BSMain
.
computerS
.
ShipPlacer
(
BSMain
.
computerS
,
BSMain
.
ships
.
get
(
i
),
x
,
y
);
BSMain
.
computerS
.
ShipPlacer
(
BSMain
.
computerS
,
BSMain
.
ships
.
get
(
i
),
x
,
y
);
...
...
src/ShipClass.java
View file @
7ca9d1b4
...
@@ -32,7 +32,7 @@ public class ShipClass {
...
@@ -32,7 +32,7 @@ public class ShipClass {
String
name
;
String
name
;
public
void
ShipPlacer
(
ShipClass
plyr
,
String
shipType
,
String
x
,
String
y
)
{
public
ArrayList
ShipPlacer
(
ShipClass
plyr
,
String
shipType
,
String
x
,
String
y
)
{
...
@@ -175,7 +175,8 @@ public class ShipClass {
...
@@ -175,7 +175,8 @@ public class ShipClass {
System
.
out
.
println
(
"Type of ship not valid or already placed for that type"
);
System
.
out
.
println
(
"Type of ship not valid or already placed for that type"
);
}
}
return
moves
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment