Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Project1Othello
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
9831113
Project1Othello
Commits
36de7cba
Commit
36de7cba
authored
Apr 13, 2020
by
amir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Printing turns and pass
parent
5ad9f2e8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
5 deletions
+39
-5
Console.java
Console.java
+6
-0
Display.java
Display.java
+6
-0
Graphic.java
Graphic.java
+8
-0
Main.java
Main.java
+19
-5
No files found.
Console.java
View file @
36de7cba
...
...
@@ -44,4 +44,10 @@ public class Console extends Display {
inputs
[
0
]
=
f
[
2
]
-
'A'
+
1
;
return
inputs
;
}
@Override
public
String
printing
(
String
toPrint
,
int
playerNumber
)
{
System
.
out
.
println
(
super
.
printing
(
toPrint
,
playerNumber
));
return
super
.
printing
(
toPrint
,
playerNumber
);
}
}
Display.java
View file @
36de7cba
...
...
@@ -19,4 +19,10 @@ public class Display {
int
[]
input
=
new
int
[
2
];
return
input
;
}
public
String
printing
(
String
toPrint
,
int
playerNumber
){
if
(
toPrint
.
equals
(
"Player"
))
return
"Player"
+
playerNumber
+
", it's your turn"
;
return
toPrint
;
}
}
Graphic.java
View file @
36de7cba
...
...
@@ -348,4 +348,12 @@ public class Graphic extends Display {
}
return
ints
;
}
@Override
public
String
printing
(
String
toPrint
,
int
playerNumber
)
{
b
.
setVisible
(
false
);
b
.
setText
(
super
.
printing
(
toPrint
,
playerNumber
));
b
.
setVisible
(
true
);
return
super
.
printing
(
toPrint
,
playerNumber
);
}
}
Main.java
View file @
36de7cba
...
...
@@ -3,6 +3,7 @@ package com.company;
import
java.util.Scanner
;
import
java.util.Timer
;
public
class
Main
{
...
...
@@ -30,22 +31,35 @@ public class Main {
turns
++;
if
(
turns
%
2
==
1
){
if
(
play1
.
numberOfPlayerPossibleMoves
(
play2
.
getArr2
(),
play1
.
getArr1
())
!=
0
)
{
if
()
System
.
out
.
println
(
"Player1, it's your turn!"
);
if
(
displayType
==
0
)
console
.
printing
(
"Player"
,
1
);
else
graphic
.
printing
(
"Player"
,
1
);
}
else
{
//if there is no possible move prints pass
System
.
out
.
println
(
"pass"
);
if
(
displayType
==
0
)
console
.
printing
(
"pass"
,
1
);
else
graphic
.
printing
(
"pass"
,
1
);
turns
++;
}
}
if
(
turns
%
2
==
0
){
if
(
play2
.
numberOfPlayerPossibleMoves
(
play1
.
getArr1
(),
play2
.
getArr2
())
!=
0
)
{
//System.out.println("Player2, it's your turn!");
if
(
play1
.
numberOfPlayerPossibleMoves
(
play2
.
getArr2
(),
play1
.
getArr1
())
!=
0
)
{
if
(
displayType
==
0
)
console
.
printing
(
"Player"
,
2
);
else
graphic
.
printing
(
"Player"
,
2
);
}
}
else
{
//if there is no possible move prints pass
System
.
out
.
println
(
"pass"
);
if
(
displayType
==
0
)
console
.
printing
(
"pass"
,
2
);
else
graphic
.
printing
(
"pass"
,
2
);
continue
;
}
}
...
...
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