Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
Othello_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
Othello_9731301
Commits
e367a058
Commit
e367a058
authored
Apr 01, 2020
by
9731301
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Othello class with suitable input and output_add name to user
parent
e19b199d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
167 additions
and
16 deletions
+167
-16
workspace.xml
.idea/workspace.xml
+14
-13
Othello.class
out/production/MyOthello/Othello.class
+0
-0
User.class
out/production/MyOthello/User.class
+0
-0
Othello.java
src/Othello.java
+140
-0
User.java
src/User.java
+13
-3
No files found.
.idea/workspace.xml
View file @
e367a058
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"7be08370-19a4-4528-ab9b-d4cb0ec736c4"
name=
"Default Changelist"
comment=
""
>
<list
default=
"true"
id=
"7be08370-19a4-4528-ab9b-d4cb0ec736c4"
name=
"Default Changelist"
comment=
""
>
<change
afterPath=
"$PROJECT_DIR$/.idea/vcs.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/User.java"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/MyOthello/Othello.class"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/out/production/MyOthello/Othello.class"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/MyOthello/User.class"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/out/production/MyOthello/User.class"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/User.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/User.java"
afterDir=
"false"
/>
</list>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
...
@@ -62,7 +63,7 @@
...
@@ -62,7 +63,7 @@
<workItem
from=
"1585656097487"
duration=
"2378000"
/>
<workItem
from=
"1585656097487"
duration=
"2378000"
/>
<workItem
from=
"1585659438353"
duration=
"9321000"
/>
<workItem
from=
"1585659438353"
duration=
"9321000"
/>
<workItem
from=
"1585687211713"
duration=
"16102000"
/>
<workItem
from=
"1585687211713"
duration=
"16102000"
/>
<workItem
from=
"1585733466673"
duration=
"
521
000"
/>
<workItem
from=
"1585733466673"
duration=
"
3514
000"
/>
</task>
</task>
<servers
/>
<servers
/>
</component>
</component>
...
@@ -70,26 +71,26 @@
...
@@ -70,26 +71,26 @@
<option
name=
"version"
value=
"1"
/>
<option
name=
"version"
value=
"1"
/>
</component>
</component>
<component
name=
"WindowStateProjectService"
>
<component
name=
"WindowStateProjectService"
>
<state
x=
"574"
y=
"97"
key=
"#com.intellij.ide.util.MemberChooser"
timestamp=
"1585
694421216
"
>
<state
x=
"574"
y=
"97"
key=
"#com.intellij.ide.util.MemberChooser"
timestamp=
"1585
736657332
"
>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
</state>
</state>
<state
x=
"574"
y=
"97"
key=
"#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824"
timestamp=
"1585
694421216
"
/>
<state
x=
"574"
y=
"97"
key=
"#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824"
timestamp=
"1585
736657332
"
/>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1585703421720
"
>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1585738348489
"
>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
</state>
</state>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824"
timestamp=
"1585703421720
"
/>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824"
timestamp=
"1585738348489
"
/>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.center"
timestamp=
"1585703421720
"
>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.center"
timestamp=
"1585738348488
"
>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
</state>
</state>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824"
timestamp=
"1585703421720
"
/>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824"
timestamp=
"1585738348488
"
/>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.left"
timestamp=
"1585703421720
"
>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.left"
timestamp=
"1585738348488
"
>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
</state>
</state>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824"
timestamp=
"1585703421720
"
/>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824"
timestamp=
"1585738348488
"
/>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.right"
timestamp=
"1585703421720
"
>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.right"
timestamp=
"1585738348488
"
>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
</state>
</state>
<state
width=
"1493"
height=
"2
01"
key=
"GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824"
timestamp=
"1585703421720
"
/>
<state
width=
"1493"
height=
"2
50"
key=
"GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824"
timestamp=
"1585738348488
"
/>
<state
width=
"1493"
height=
"182"
key=
"GridCell.Tab.1.bottom"
timestamp=
"1585671521268"
>
<state
width=
"1493"
height=
"182"
key=
"GridCell.Tab.1.bottom"
timestamp=
"1585671521268"
>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
<screen
x=
"0"
y=
"0"
width=
"1536"
height=
"824"
/>
</state>
</state>
...
...
out/production/MyOthello/Othello.class
View file @
e367a058
No preview for this file type
out/production/MyOthello/User.class
View file @
e367a058
No preview for this file type
src/Othello.java
0 → 100644
View file @
e367a058
import
java.util.ArrayList
;
import
java.util.Scanner
;
public
class
Othello
{
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
ArrayList
<
Block
>
blocks
=
new
ArrayList
<
Block
>();
User
user1
=
new
User
();
User
user2
=
new
User
();
Character
c
=
'n'
;
int
numberOfEmptyBlocksAtTheEnd
=
0
;
int
row
;
int
column
;
Block
block
;
Block
chosenBlock
=
new
Block
();
chosenBlock
.
setColor
(
'w'
);
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
for
(
int
j
=
0
;
j
<
8
;
j
++)
{
block
=
new
Block
();
block
.
setRow
(
i
);
block
.
setColumn
(
j
);
blocks
.
add
(
block
);
if
((
i
==
3
&&
j
==
3
)
||
(
i
==
4
&&
j
==
4
))
block
.
setColor
(
'b'
);
else
if
((
i
==
4
&&
j
==
3
)
||
(
i
==
3
&&
j
==
4
))
block
.
setColor
(
'w'
);
else
block
.
setColor
(
'n'
);
}
}
System
.
out
.
println
(
"plz enter user1 name"
);
user1
.
setName
(
sc
.
nextLine
().
trim
());
while
(!(
c
.
equals
(
'b'
)
||
c
.
equals
(
'w'
)))
{
System
.
out
.
println
(
"plz enter user1 color w or b"
);
c
=
sc
.
next
().
charAt
(
0
);
user1
.
setColor
(
c
);
}
System
.
out
.
println
(
"plz enter user2 name"
);
user2
.
setName
(
sc
.
next
());
if
(
user1
.
getColor
().
equals
(
'w'
))
user2
.
setColor
(
'b'
);
else
user2
.
setColor
(
'w'
);
System
.
out
.
println
(
user1
.
getName
()+
" color is "
+
user1
.
getColor
()+
" and "
+
user2
.
getName
()+
" color is "
+
user2
.
getColor
());
System
.
out
.
println
(
" a b c d e f g h"
);
for
(
int
i
=
0
;
i
<
8
;
i
++){
System
.
out
.
print
(
i
+
1
+
" "
);
for
(
int
j
=
0
;
j
<
8
;
j
++){
for
(
Block
b
:
blocks
){
if
(
b
.
getRow
()
==
i
&&
b
.
getColumn
()
==
j
){
System
.
out
.
print
(
b
.
getColor
()+
" "
);
}
}
}
System
.
out
.
println
();
}
while
(
true
)
{
System
.
out
.
println
(
"plz enter your choice for example :3 a"
);
chosenBlock
.
changeColor
();
System
.
out
.
println
(
"turn is for : "
+
chosenBlock
.
getColor
());
String
input
=
sc
.
nextLine
().
trim
();
String
[]
inputArray
=
input
.
split
(
" "
);
System
.
out
.
println
(
inputArray
[
0
]);
row
=
Integer
.
parseInt
(
inputArray
[
0
])-
1
;
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"a"
))
column
=
0
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"b"
))
column
=
1
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"c"
))
column
=
2
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"d"
))
column
=
3
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"e"
))
column
=
4
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"f"
))
column
=
5
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"g"
))
column
=
6
;
else
if
(
inputArray
[
1
].
toLowerCase
().
equals
(
"h"
))
column
=
7
;
else
{
System
.
out
.
println
(
"enter again correctly"
);
break
;
}
chosenBlock
.
setRow
(
row
);
chosenBlock
.
setColumn
(
column
);
System
.
out
.
println
(
" a b c d e f g h "
);
for
(
int
i
=
0
;
i
<
8
;
i
++){
System
.
out
.
print
(
i
+
1
+
" "
);
for
(
int
j
=
0
;
j
<
8
;
j
++){
for
(
Block
b
:
blocks
){
if
(
b
.
getRow
()
==
i
&&
b
.
getColumn
()
==
j
){
System
.
out
.
print
(
b
.
getColor
()+
" "
);
}
}
}
System
.
out
.
println
();
}
for
(
Block
b
:
blocks
){
if
(
b
.
getColor
().
equals
(
user1
.
getColor
())){
user1
.
addBlock
(
b
);
}
else
if
(
b
.
getColor
().
equals
(
user2
.
getColor
())){
user2
.
addBlock
(
b
);
}
else
{
numberOfEmptyBlocksAtTheEnd
++;
}
if
(
user1
.
isAvailableBlockToPick
(
b
,
blocks
)){
user1
.
addAvailableBlockToPick
(
b
);
}
else
{
user1
.
removeAvailableBlockToPick
(
b
);
}
if
(
user2
.
isAvailableBlockToPick
(
b
,
blocks
)){
user2
.
addAvailableBlockToPick
(
b
);
}
else
{
user2
.
removeAvailableBlockToPick
(
b
);
}
}
}
}
}
src/User.java
View file @
e367a058
import
java.util.ArrayList
;
import
java.util.ArrayList
;
public
class
User
{
public
class
User
{
private
String
name
;
private
ArrayList
<
Block
>
userBlocks
;
private
ArrayList
<
Block
>
userBlocks
;
private
ArrayList
<
Block
>
availableBlocksToPick
;
private
ArrayList
<
Block
>
availableBlocksToPick
;
private
cha
r
color
;
private
Characte
r
color
;
public
User
(){
public
User
(){
userBlocks
=
new
ArrayList
<
Block
>();
userBlocks
=
new
ArrayList
<
Block
>();
...
@@ -220,13 +221,22 @@ public class User {
...
@@ -220,13 +221,22 @@ public class User {
availableBlocksToPick
.
remove
(
block
);
availableBlocksToPick
.
remove
(
block
);
}
}
public
cha
r
getColor
()
{
public
Characte
r
getColor
()
{
return
color
;
return
color
;
}
}
public
void
setColor
(
cha
r
color
)
{
public
void
setColor
(
Characte
r
color
)
{
this
.
color
=
color
;
this
.
color
=
color
;
}
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
}
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