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
c6018061
Commit
c6018061
authored
May 17, 2019
by
Darth Vernon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Computer input comments
parent
85916d50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
ComputerInput.java
src/ComputerInput.java
+6
-6
No files found.
src/ComputerInput.java
View file @
c6018061
...
...
@@ -2,11 +2,11 @@ import java.util.ArrayList;
import
java.util.Random
;
public
class
ComputerInput
{
static
String
cmptrWin
[]
=
{
"DIE"
,
"Yesss"
,
"To easy"
};
static
String
cmptrWin
[]
=
{
"DIE"
,
"Yesss"
,
"To easy"
};
//Responses to win / loss.
static
String
cmptrLose
[]
=
{
"Noooo"
,
"How can this be"
,
"Cheat!"
};
Boolean
win
=
false
;
public
static
String
talk
(
Boolean
win
)
{
public
static
String
talk
(
Boolean
win
)
{
//Picks a random response, based on win boolean.
String
speach
=
""
;
Random
rand
=
new
Random
();
if
(
win
)
{
...
...
@@ -18,7 +18,7 @@ public class ComputerInput {
return
speach
;
}
public
static
ArrayList
<
String
>
CoOrdRandomiser
()
{
public
static
ArrayList
<
String
>
CoOrdRandomiser
()
{
//Uses random numbers to index an X and a Y coordinate.
ArrayList
<
String
>
coOrd
=
new
ArrayList
<
String
>();
Random
rand
=
new
Random
();
int
indexX
=
rand
.
nextInt
(
10
);
...
...
@@ -34,7 +34,7 @@ public class ComputerInput {
public
static
void
cmptrMoveGen
()
{
public
static
void
cmptrMoveGen
()
{
//Uses input from xy randomiser to place ships and validate the moves using moveValid Check from Grid class.
...
...
@@ -46,11 +46,11 @@ public class ComputerInput {
BSMain
.
computerS
.
ShipPlacer
(
BSMain
.
computerS
,
BSMain
.
ships
.
get
(
i
),
x
,
y
);
BSMain
.
computerS
.
ShipPlacer
(
BSMain
.
computerS
,
BSMain
.
ships
.
get
(
i
),
x
,
y
);
// Places
if
(!
BSMain
.
computerG
.
MoveValidCheck
(
BSMain
.
computerG
,
BSMain
.
computerS
.
moves
,
BSMain
.
computerS
,
BSMain
.
ships
.
get
(
i
))
)
{
i
--;
i
--;
// if moves rejected , the loop is knocked back and that ship, re generated as a set of different 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