Commit 43e33a78 authored by 9731301's avatar 9731301

Add Pentago Class

parent f1c5c8de
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/src" vcs="Git" /> <mapping directory="$PROJECT_DIR$/src" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="63729159-695b-4499-ba7f-f31e81a0234c" name="Default Changelist" comment="" /> <list default="true" id="63729159-695b-4499-ba7f-f31e81a0234c" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" 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" />
</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" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -15,7 +18,7 @@ ...@@ -15,7 +18,7 @@
</option> </option>
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/src" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="ProjectId" id="1a7vHcpsUDZyxFcq1HeYNw9THGw" /> <component name="ProjectId" id="1a7vHcpsUDZyxFcq1HeYNw9THGw" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
...@@ -29,6 +32,20 @@ ...@@ -29,6 +32,20 @@
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" /> <property name="aspect.path.notification.shown" value="true" />
</component> </component>
<component name="RunManager">
<configuration name="Pentago" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Pentago" />
<module name="MyPentago" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Application.Pentago" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration"> <component name="SvnConfiguration">
<configuration /> <configuration />
</component> </component>
...@@ -41,6 +58,7 @@ ...@@ -41,6 +58,7 @@
<updated>1586099359973</updated> <updated>1586099359973</updated>
<workItem from="1586099364327" duration="87000" /> <workItem from="1586099364327" duration="87000" />
<workItem from="1586105455800" duration="97000" /> <workItem from="1586105455800" duration="97000" />
<workItem from="1586105975356" duration="8819000" />
</task> </task>
<servers /> <servers />
</component> </component>
...@@ -48,10 +66,26 @@ ...@@ -48,10 +66,26 @@
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="281" y="271" key="com.intellij.ide.util.TipDialog" timestamp="1586105456464"> <state width="1493" height="21" key="GridCell.Tab.0.bottom" timestamp="1586117772912">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="21" key="GridCell.Tab.0.bottom/0.0.1536.824@0.0.1536.824" timestamp="1586117772912" />
<state width="1493" height="21" key="GridCell.Tab.0.center" timestamp="1586117772912">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="21" key="GridCell.Tab.0.center/0.0.1536.824@0.0.1536.824" timestamp="1586117772912" />
<state width="1493" height="21" key="GridCell.Tab.0.left" timestamp="1586117772912">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="21" key="GridCell.Tab.0.left/0.0.1536.824@0.0.1536.824" timestamp="1586117772912" />
<state width="1493" height="21" key="GridCell.Tab.0.right" timestamp="1586117772912">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state width="1493" height="21" key="GridCell.Tab.0.right/0.0.1536.824@0.0.1536.824" timestamp="1586117772912" />
<state x="281" y="271" key="com.intellij.ide.util.TipDialog" timestamp="1586106017061">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="281" y="271" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1586105456464" /> <state x="281" y="271" key="com.intellij.ide.util.TipDialog/0.0.1536.824@0.0.1536.824" timestamp="1586106017061" />
<state x="25" y="67" key="new project wizard" timestamp="1586105483065"> <state x="25" y="67" key="new project wizard" timestamp="1586105483065">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
......
...@@ -19,8 +19,8 @@ public class Block { ...@@ -19,8 +19,8 @@ public class Block {
} }
public void createCells(){ public void createCells(){
Cell cell = new Cell();
for (int i = 0 ; i < 9 ; i++ ){ for (int i = 0 ; i < 9 ; i++ ){
Cell cell = new Cell();
cell.setNumber(i);; cell.setNumber(i);;
cell.setColor('O'); cell.setColor('O');
allCells.add(cell); allCells.add(cell);
......
import java.util.ArrayList;
import java.util.Scanner;
public class Pentago {
public static void main(String [] args){
ArrayList<Block> blocks = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
User user1 = new User();
User user2 = new User();
User chosenUser = new User();
chosenUser = user2;
user1.setColor('⚫');
user2.setColor('m');
int blockNumber;
int cellNumber;
int i , j ;
String turn;
for ( i = 0 ; i < 4 ; i++ ){
Block block = new Block();
block.createCells();
block.setNumber(i);
blocks.add(block);
}
j = 0 ;
for ( i = 0 ; i < 4 ;){
System.out.print("| " + blocks.get(i).getAllCells().get(j).getColor()+ " "+ blocks.get(i).getAllCells().get(j++).getColor() +" "+ blocks.get(i).getAllCells().get(j++).getColor() + " |");
if ( i == 3 && j == 8){
break;
}
if ((i == 0 || i == 2) && j == 2 ){
i++;
j = 0;
}
else if ((i == 0 || i == 2 ) && j == 5){
i++;
j = 3;
}
else if(( i == 0 || i == 2 ) && j == 8){
i++;
j = 6;
}
else if (( i == 1 )&& j == 8){
i = 2 ;
j = 0 ;
System.out.println("\n------------------");
continue;
}
else if ( (j == 2 || j == 5 ) && ( i == 1 || i == 3)){
i--;
j++;
System.out.println();
}
}
while (true) {
if (chosenUser.equals(user1)){
chosenUser = user2;
}
else {
chosenUser = user1;
}
System.out.println("\nplz enter a block number");
blockNumber = scanner.nextInt()-1;
System.out.println("plz enter a cell number");
cellNumber = scanner.nextInt()-1;
if (chosenUser.cellIsAvailableToTake(blocks.get(blockNumber).getAllCells().get(cellNumber))) {
blocks.get(blockNumber).getAllCells().get(cellNumber).setColor(chosenUser.getColor());
System.out.println(blocks.get(blockNumber).getAllCells().get(cellNumber).getColor());
}
// System.out.println("plz enter how change position? right/left");
// turn = scanner.next().trim();
// blocks.get(blockNumber).changePositionOfBlock(turn);
j = 0 ;
for ( i = 0 ; i < 4 ;){
System.out.print("| " + blocks.get(i).getAllCells().get(j).getColor()+ " "+ blocks.get(i).getAllCells().get(j+1).getColor() +" "+ blocks.get(i).getAllCells().get(j+2).getColor() + " |");
if ( i == 3 && j == 8){
break;
}
if ((i == 0 || i == 2) && j == 2 ){
i++;
j = 0;
}
else if ((i == 0 || i == 2 ) && j == 5){
i++;
j = 3;
}
else if(( i == 0 || i == 2 ) && j == 8){
i++;
j = 6;
}
else if (( i == 1 )&& j == 8){
i = 2 ;
j = 0 ;
System.out.println("\n------------------");
continue;
}
else if ( (j == 2 || j == 5 ) && ( i == 1 || i == 3)){
i--;
j++;
System.out.println();
}
}
}
}
}
...@@ -3,7 +3,6 @@ import java.util.ArrayList; ...@@ -3,7 +3,6 @@ import java.util.ArrayList;
public class User { public class User {
private ArrayList<Cell> takenCells; private ArrayList<Cell> takenCells;
private Character color; private Character color;
private int number;
public User(){ public User(){
takenCells = new ArrayList<Cell>(); takenCells = new ArrayList<Cell>();
......
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