Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
AP Lab 7
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
Omid Sayfun
AP Lab 7
Commits
59b24e08
Commit
59b24e08
authored
Apr 27, 2019
by
Omid Sayfun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy Up
parent
6240c6aa
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
55 additions
and
30 deletions
+55
-30
Main.java
Main.java
+5
-30
Bishop.java
lab/game/Bishop.java
+1
-0
Board.java
lab/game/Board.java
+1
-0
King.java
lab/game/King.java
+1
-0
Knight.java
lab/game/Knight.java
+1
-0
Pawn.java
lab/game/Pawn.java
+1
-0
Piece.java
lab/game/Piece.java
+2
-0
Queen.java
lab/game/Queen.java
+1
-0
Rook.java
lab/game/Rook.java
+1
-0
Observ.java
lab/observ/Observ.java
+41
-0
No files found.
Main.java
View file @
59b24e08
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.io.IOException
;
import
lab.observ.*
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
Board
mainBoard
=
new
Board
();
mainBoard
.
initPieces
();
// mainBoard.printHelp();
String
player
=
"W"
;
for
(
int
i
=
0
;
i
<
500
;
i
++){
while
(
true
){
new
ProcessBuilder
(
"cmd"
,
"/c"
,
"cls"
).
inheritIO
().
start
().
waitFor
();
mainBoard
.
printBoard
();
if
(
player
.
equals
(
"W"
)
){
System
.
out
.
print
(
"White "
);
}
else
{
System
.
out
.
print
(
"Black "
);
}
System
.
out
.
print
(
"Player Move: "
);
String
input
=
sc
.
nextLine
();
// Check if input is valid
if
(
mainBoard
.
move
(
input
.
split
(
" "
)[
0
],
input
.
split
(
" "
)[
1
],
player
)
){
break
;
}
}
if
(
player
.
equals
(
"W"
)
){
// Change PLayer
player
=
"B"
;
}
else
{
player
=
"W"
;
}
try
{
Observ
.
start
();
}
catch
(
IOException
e
){
e
.
printStackTrace
();
}
sc
.
close
();
}
}
Bishop.java
→
lab/game/
Bishop.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
Bishop
extends
Piece
{
...
...
Board.java
→
lab/game/
Board.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
Board
{
...
...
King.java
→
lab/game/
King.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
King
extends
Piece
{
...
...
Knight.java
→
lab/game/
Knight.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
Knight
extends
Piece
{
...
...
Pawn.java
→
lab/game/
Pawn.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
Pawn
extends
Piece
{
...
...
Piece.java
→
lab/game/
Piece.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
abstract
class
Piece
{
protected
int
y
;
protected
char
x
;
...
...
Queen.java
→
lab/game/
Queen.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
Queen
extends
Piece
{
...
...
Rook.java
→
lab/game/
Rook.java
View file @
59b24e08
package
lab
.
game
;
import
java.util.*
;
public
class
Rook
extends
Piece
{
...
...
lab/observ/Observ.java
0 → 100644
View file @
59b24e08
package
lab
.
observ
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.io.IOException
;
import
lab.game.*
;
public
class
Observ
{
public
static
void
start
()
throws
IOException
,
InterruptedException
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
Board
mainBoard
=
new
Board
();
mainBoard
.
initPieces
();
// mainBoard.printHelp();
String
player
=
"W"
;
for
(
int
i
=
0
;
i
<
500
;
i
++){
while
(
true
){
new
ProcessBuilder
(
"cmd"
,
"/c"
,
"cls"
).
inheritIO
().
start
().
waitFor
();
mainBoard
.
printBoard
();
if
(
player
.
equals
(
"W"
)
){
System
.
out
.
print
(
"White "
);
}
else
{
System
.
out
.
print
(
"Black "
);
}
System
.
out
.
print
(
"Player Move: "
);
String
input
=
sc
.
nextLine
();
// Check if input is valid
if
(
mainBoard
.
move
(
input
.
split
(
" "
)[
0
],
input
.
split
(
" "
)[
1
],
player
)
){
break
;
}
}
if
(
player
.
equals
(
"W"
)
){
// Change PLayer
player
=
"B"
;
}
else
{
player
=
"W"
;
}
}
sc
.
close
();
}
}
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