Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
Chess_2
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
9731039
Chess_2
Commits
84749e14
Commit
84749e14
authored
Apr 28, 2019
by
Parsa Safaei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
5aae2a80
Pipeline
#531
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
4 deletions
+83
-4
Field.java
src/Field.java
+3
-2
Main.java
src/Main.java
+1
-0
Man.java
src/Man.java
+79
-2
No files found.
src/Field.java
View file @
84749e14
package
PACKAGE_NAME
;
public
class
Field
{
private
boolean
isFree
;
private
int
num
;
private
char
letter
;
}
src/Main.java
View file @
84749e14
public
class
Main
{
}
src/Man.java
View file @
84749e14
package
PACKAGE_NAME
;
public
class
Man
{
}
private
char
color
;
private
int
num
;
private
char
letter
;
private
String
type
;
boolean
hasMoved
;
public
Man
(
char
color
,
int
num
,
char
letter
,
String
type
)
{
this
.
color
=
color
;
this
.
num
=
num
;
this
.
letter
=
letter
;
this
.
type
=
type
;
this
.
hasMoved
=
false
;
}
public
boolean
move
(
int
num
,
char
letter
)
{
if
(
this
.
type
.
equals
(
"king"
)
&&
Math
.
abs
(
num
-
this
.
num
)
<=
1
&&
Math
.
abs
((
int
)
letter
-
(
int
)
this
.
letter
)
<=
1
)
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
else
if
(
this
.
type
.
equals
(
"queen"
)
&&
((
num
==
this
.
num
||
letter
==
this
.
letter
)
||
(
Math
.
abs
(
num
-
this
.
num
)
==
Math
.
abs
((
int
)
letter
-
(
int
)
this
.
letter
))))
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
else
if
(
this
.
type
.
equals
(
"rook"
)
&&
(
num
==
this
.
num
||
letter
==
this
.
letter
))
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
else
if
(
this
.
type
.
equals
(
"bishop"
)
&&
Math
.
abs
(
num
-
this
.
num
)
==
Math
.
abs
((
int
)
letter
-
(
int
)
this
.
letter
))
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
else
if
(
this
.
type
.
equals
(
"knight"
)
&&
(
Math
.
abs
(
num
-
this
.
num
)
==
1
&&
Math
.
abs
((
int
)
letter
-
(
int
)
this
.
letter
)
==
2
)
||
(
Math
.
abs
(
num
-
this
.
num
)
==
2
&&
Math
.
abs
((
int
)
letter
-
(
int
)
this
.
letter
)
==
1
))
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
else
if
(
this
.
type
.
equals
(
"soldier"
))
{
if
(
this
.
color
==
'w'
)
{
if
(!
this
.
hasMoved
&&
num
-
this
.
num
==
2
)
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
if
(
this
.
hasMoved
&&
num
-
this
.
num
==
1
)
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
}
else
if
(
this
.
color
==
'b'
)
{
if
(!
this
.
hasMoved
&&
num
-
this
.
num
==
-
2
)
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
if
(
this
.
hasMoved
&&
num
-
this
.
num
==
-
1
)
{
this
.
num
=
num
;
this
.
letter
=
letter
;
hasMoved
=
true
;
return
true
;
}
}
}
System
.
out
.
println
(
"Wrong Input!"
);
return
false
;
}
}
\ No newline at end of file
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