Commit b95e5b9d authored by 9731301's avatar 9731301

Add calculations the winner Othello class

parent afc1cdc2
......@@ -2,6 +2,10 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7be08370-19a4-4528-ab9b-d4cb0ec736c4" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="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/Othello.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Othello.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/User.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -60,7 +64,9 @@
<workItem from="1585656097487" duration="2378000" />
<workItem from="1585659438353" duration="9321000" />
<workItem from="1585687211713" duration="16102000" />
<workItem from="1585733466673" duration="3956000" />
<workItem from="1585733466673" duration="4235000" />
<workItem from="1585743679588" duration="17656000" />
<workItem from="1585769658377" duration="6434000" />
</task>
<servers />
</component>
......@@ -68,45 +74,49 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser" timestamp="1585736657332">
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser" timestamp="1585772436513">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1585736657332" />
<state width="1493" height="250" key="GridCell.Tab.0.bottom" timestamp="1585738348489">
<state x="574" y="97" key="#com.intellij.ide.util.MemberChooser/0.0.1536.824@0.0.1536.824" timestamp="1585772436513" />
<state width="1493" height="63" key="GridCell.Tab.0.bottom" timestamp="1585776104986">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1585738348489" />
<state width="1493" height="250" key="GridCell.Tab.0.center" timestamp="1585738348488">
<state width="1493" height="63" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1585776104986" />
<state width="1493" height="63" key="GridCell.Tab.0.center" timestamp="1585776104985">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1585738348488" />
<state width="1493" height="250" key="GridCell.Tab.0.left" timestamp="1585738348488">
<state width="1493" height="63" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1585776104985" />
<state width="1493" height="63" key="GridCell.Tab.0.left" timestamp="1585776104985">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1585738348488" />
<state width="1493" height="250" key="GridCell.Tab.0.right" timestamp="1585738348488">
<state width="1493" height="63" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1585776104985" />
<state width="1493" height="63" key="GridCell.Tab.0.right" timestamp="1585776104985">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="250" 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="63" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1585776104985" />
<state width="1493" height="331" key="GridCell.Tab.1.bottom" timestamp="1585762030361">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="182" key="GridCell.Tab.1.bottom/0.0.1536.824@0.0.1536.824" timestamp="1585671521268" />
<state width="1493" height="182" key="GridCell.Tab.1.center" timestamp="1585671521268">
<state width="1493" height="331" key="GridCell.Tab.1.bottom/0.0.1536.824@0.0.1536.824" timestamp="1585762030361" />
<state width="1493" height="331" key="GridCell.Tab.1.center" timestamp="1585762030361">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="182" key="GridCell.Tab.1.center/0.0.1536.824@0.0.1536.824" timestamp="1585671521268" />
<state width="1493" height="182" key="GridCell.Tab.1.left" timestamp="1585671521267">
<state width="1493" height="331" key="GridCell.Tab.1.center/0.0.1536.824@0.0.1536.824" timestamp="1585762030361" />
<state width="1493" height="331" key="GridCell.Tab.1.left" timestamp="1585762030361">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="182" key="GridCell.Tab.1.left/0.0.1536.824@0.0.1536.824" timestamp="1585671521267" />
<state width="1493" height="182" key="GridCell.Tab.1.right" timestamp="1585671521268">
<state width="1493" height="331" key="GridCell.Tab.1.left/0.0.1536.824@0.0.1536.824" timestamp="1585762030361" />
<state width="1493" height="331" key="GridCell.Tab.1.right" timestamp="1585762030361">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="182" key="GridCell.Tab.1.right/0.0.1536.824@0.0.1536.824" timestamp="1585671521268" />
<state x="813" y="283" key="com.intellij.ide.util.TipDialog" timestamp="1585733471645">
<state width="1493" height="331" key="GridCell.Tab.1.right/0.0.1536.824@0.0.1536.824" timestamp="1585762030361" />
<state x="813" y="283" key="com.intellij.ide.util.TipDialog" timestamp="1585769711025">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="813" y="283" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1585733471645" />
<state x="813" y="283" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1585769711025" />
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1585744923229">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="431" y="145" width="672" height="678" key="search.everywhere.popup/0.0.1536.824@0.0.1536.824" timestamp="1585744923229" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -14,9 +14,13 @@ public class User {
userBlocks.add(block);
}
public void removeBlock(Block block){
userBlocks.remove(block);
}
public boolean isAvailableBlockToPick(Block block , ArrayList<Block> blocks ) {
int i, j;
int flag1 = 0;
int flag1 = 0;// for checking neighbors has same color in each step or not
int flag2 = 0;
int flag3 = 0;// to know you can pick an empty block with help of checking changing color
if (!block.getColor().equals('n')) {
......@@ -26,7 +30,7 @@ public class User {
//check down
for (i = block.getRow(); i > 8; i++) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getRow() == block.getRow() + 1 && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() && block1.getRow() == block.getRow() + 1 && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -46,9 +50,9 @@ public class User {
//check up
flag1 = 0;
flag2 = 0;
for (i = block.getRow() - 1; i >= 0; i--) {// find the next block with chosen block color
for (i = block.getRow() - 1; i > -1; i--) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getRow() == block.getRow() - 1 && block1.getColumn() == block.getColumn() && block1.getColor().equals(color)) {
if (block1.getRow() == block.getRow() - 1 && block1.getColumn() == block.getColumn() && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -70,7 +74,7 @@ public class User {
flag2 = 0;
for (i = block.getColumn() + 1; i < 8; i++) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getColumn() == block.getColumn() + 1 && block1.getRow() == block.getRow() && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() + 1 && block1.getRow() == block.getRow() && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -90,9 +94,9 @@ public class User {
//check left
flag1 = 0;
flag2 = 0;
for (i = block.getColumn() - 1; i >= 0; i--) {// find the next block with chosen block color
for (i = block.getColumn() - 1; i > -1; i--) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getColumn() == block.getColumn() - 1 && block1.getRow() == block.getRow() && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() - 1 && block1.getRow() == block.getRow() &&( block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -115,7 +119,7 @@ public class User {
flag2 = 0;
for (i = block.getColumn() + 1, j = block.getRow() - 1; i < 8 && j > -1; i++, j--) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getColumn() == block.getColumn() + 1 && block1.getRow() == block.getRow() + 1 && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() + 1 && block1.getRow() == block.getRow() + 1 && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -137,7 +141,7 @@ public class User {
flag2 = 0;
for (i = block.getColumn() - 1, j = block.getRow() + 1; i > -1 && j < 8; i--, j++) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getColumn() == block.getColumn() - 1 && block1.getRow() == block.getRow() + 1 && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() - 1 && block1.getRow() == block.getRow() + 1 && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -159,7 +163,7 @@ public class User {
flag2 = 0;
for (i = block.getColumn() + 1, j = block.getRow() + 1; i < 8 && j < 8; i++, j++) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getColumn() == block.getColumn() + 1 && block1.getRow() == block.getRow() - 1 && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() + 1 && block1.getRow() == block.getRow() - 1 && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -179,9 +183,9 @@ public class User {
//check up and left
flag1 = 0;
flag2 = 0;
for (i = block.getColumn() - 1, j = block.getRow() - 1; i < -1 && j < -1; i--, j--) {// find the next block with chosen block color
for (i = block.getColumn() - 1, j = block.getRow() - 1; i > -1 && j > -1; i--, j--) {// find the next block with chosen block color
for (Block block1 : blocks) {
if (block1.getColumn() == block.getColumn() - 1 && block1.getRow() == block.getRow() - 1 && block1.getColor().equals(color)) {
if (block1.getColumn() == block.getColumn() - 1 && block1.getRow() == block.getRow() - 1 && (block1.getColor().equals(color) || block1.getColor().equals('n'))) {
flag1 = 1;
break;
}
......@@ -238,5 +242,20 @@ public class User {
this.name = name;
}
public ArrayList<Block> getAvailableBlocksToPick() {
return availableBlocksToPick;
}
public void setAvailableBlocksToPick(ArrayList<Block> availableBlocksToPick) {
this.availableBlocksToPick = availableBlocksToPick;
}
public ArrayList<Block> getUserBlocks() {
return userBlocks;
}
public void setUserBlocks(ArrayList<Block> userBlocks) {
this.userBlocks = userBlocks;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment