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
william.hill1
battleships
Commits
7a5b9d15
Commit
7a5b9d15
authored
Apr 03, 2019
by
william.hill1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
need to fix loop
parent
526d7841
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
4 deletions
+73
-4
Main.java
src/Main.java
+73
-4
No files found.
src/Main.java
View file @
7a5b9d15
import
javafx.application.Application
;
import
javafx.scene.Group
;
import
javafx.scene.paint.Color
;
import
javafx.scene.shape.Rectangle
;
import
javafx.stage.Stage
;
import
javafx.scene.Scene
;
public
class
Main
{
public
class
Main
extends
Application
{
public
void
start
(
Stage
stage
)
{
int
Boardsize
=
10
;
int
[][]
PlayerShips
=
new
int
[
Boardsize
][
Boardsize
];
Rectangle
[][]
playerRects
=
new
Rectangle
[
Boardsize
][
Boardsize
];
Group
group
=
new
Group
();
{
for
(
int
y
=
0
;
y
<
10
;
++
y
)
{
for
(
int
x
=
0
;
x
<
10
;
++
x
)
{
Rectangle
r
=
new
Rectangle
();
r
.
setX
(
90
*
x
);
r
.
setY
(
90
*
y
);
r
.
setWidth
(
90
);
r
.
setHeight
(
90
);
r
.
setFill
(
Color
.
BLUE
);
r
.
setStroke
(
Color
.
WHITE
);
group
.
getChildren
().
add
(
r
);
playerRects
[
x
][
y
]
=
r
;
final
int
xc
=
x
;
final
int
yc
=
y
;
r
.
setOnMouseClicked
(
event
->
{
int
legnth
=
5
;
System
.
out
.
println
(
"click at "
+
xc
+
" "
+
yc
);
for
(
int
i
=
0
;
i
<
legnth
;
i
++)
{
legnth
--;
System
.
out
.
println
(
legnth
);
playerRects
[
xc
][
yc
].
setFill
(
Color
.
GREEN
);
playerRects
[
xc
+
i
][
yc
].
setFill
(
Color
.
GREEN
);
}
});
}
}
Scene
scene
=
new
Scene
(
group
,
900
,
900
);
stage
.
setScene
(
scene
);
stage
.
show
();
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Battleships"
);
launch
(
args
);
System
.
out
.
println
(
"Hello world"
);
System
.
out
.
println
(
"Hello world again"
);
}
}
}
}
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