Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Pentago_9731301
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
9731301
Pentago_9731301
Commits
c6186266
Commit
c6186266
authored
Apr 05, 2020
by
9731301
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Cell Class and Block Class
parents
Pipeline
#3250
failed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
0 deletions
+101
-0
Block.java
Block.java
+77
-0
Cell.java
Cell.java
+24
-0
No files found.
Block.java
0 → 100644
View file @
c6186266
import
java.util.ArrayList
;
public
class
Block
{
private
ArrayList
<
Cell
>
allCells
;
private
int
number
;
private
String
turn
;
public
Block
(){
allCells
=
new
ArrayList
<>();
}
public
int
getNumber
()
{
return
number
;
}
public
void
setNumber
(
int
number
)
{
this
.
number
=
number
;
}
public
void
createCells
(){
Cell
cell
=
new
Cell
();
for
(
int
i
=
0
;
i
<
9
;
i
++
){
cell
.
setNumber
(
i
);;
cell
.
setColor
(
'O'
);
allCells
.
add
(
cell
);
}
}
public
void
changePositionOfBlock
(
String
turn
){
Cell
transporterCell
;
if
(
turn
.
equals
(
"right"
)){
allCells
.
add
(
2
,
allCells
.
get
(
0
));
allCells
.
remove
(
0
);
allCells
.
add
(
0
,
allCells
.
get
(
2
));
allCells
.
remove
(
3
);
allCells
.
add
(
5
,
allCells
.
get
(
1
));
allCells
.
remove
(
1
);
allCells
.
add
(
1
,
allCells
.
get
(
5
));
allCells
.
remove
(
6
);
allCells
.
add
(
8
,
allCells
.
get
(
0
));
allCells
.
remove
(
8
);
allCells
.
add
(
0
,
allCells
.
get
(
8
));
allCells
.
remove
(
9
);
allCells
.
add
(
3
,
allCells
.
get
(
1
));
allCells
.
remove
(
1
);
allCells
.
add
(
1
,
allCells
.
get
(
3
));
allCells
.
remove
(
4
);
allCells
.
add
(
6
,
allCells
.
get
(
0
));
allCells
.
remove
(
0
);
allCells
.
add
(
0
,
allCells
.
get
(
6
));
allCells
.
remove
(
7
);
allCells
.
add
(
7
,
allCells
.
get
(
3
));
allCells
.
remove
(
3
);
allCells
.
add
(
3
,
allCells
.
get
(
7
));
allCells
.
remove
(
8
);
}
else
if
(
turn
.
equals
(
"left"
)){
turn
=
"right"
;
changePositionOfBlock
(
turn
);
changePositionOfBlock
(
turn
);
changePositionOfBlock
(
turn
);
}
else
{
System
.
out
.
println
(
"this position doesn't exist"
);
}
}
public
ArrayList
<
Cell
>
getAllCells
()
{
return
allCells
;
}
}
Cell.java
0 → 100644
View file @
c6186266
public
class
Cell
{
private
Character
color
;
private
int
number
;
public
Cell
(){
color
=
'O'
;
}
public
int
getNumber
()
{
return
number
;
}
public
void
setNumber
(
int
number
)
{
this
.
number
=
number
;
}
public
Character
getColor
()
{
return
color
;
}
public
void
setColor
(
Character
color
)
{
this
.
color
=
color
;
}
}
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