diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e7e9d11d4bf243bffe4bb60b4ac1f9392297f4bf --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..37e641e9151ca9f6d070a5d9f15bda303604a540 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="13" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..47bdc1c53a5e7dcec890c145eca1c482efd6e3d0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/tp3.iml" filepath="$PROJECT_DIR$/tp3.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/Grid.java b/Grid.java index 939e05fd8e4207e92eb7ffaedebfcd6d4d0f6d0b..3bc067bf7bef2787a2171ce96cd76cc49c28d547 100644 --- a/Grid.java +++ b/Grid.java @@ -1,7 +1,4 @@ -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Random; +import java.util.*; /** * {@code Grid} instances represent the grid in <i>The Game of Life</i>. @@ -111,7 +108,14 @@ public class Grid implements Iterable<Cell> { private List<Cell> getNeighbours(int rowIndex, int columnIndex) { - return null; + List<Cell> cells = new ArrayList<>(); + for (int i = rowIndex - 1; i <= rowIndex + 1; i++) { + for (int j = columnIndex - 1; j <= columnIndex + 1; j++) { + if (i != rowIndex && j != columnIndex || i > 0 && j > 0 && i < getNumberOfRows() && j < getNumberOfColumns()) + cells.add(getCell(i, j)); + } + } + return cells; } private void goToNextState(boolean[][] nextState) { diff --git a/out/production/tp3/.idea/.gitignore b/out/production/tp3/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e7e9d11d4bf243bffe4bb60b4ac1f9392297f4bf --- /dev/null +++ b/out/production/tp3/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/out/production/tp3/.idea/misc.xml b/out/production/tp3/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..37e641e9151ca9f6d070a5d9f15bda303604a540 --- /dev/null +++ b/out/production/tp3/.idea/misc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="13" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/out/production/tp3/.idea/modules.xml b/out/production/tp3/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..47bdc1c53a5e7dcec890c145eca1c482efd6e3d0 --- /dev/null +++ b/out/production/tp3/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/tp3.iml" filepath="$PROJECT_DIR$/tp3.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/out/production/tp3/.idea/vcs.xml b/out/production/tp3/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/out/production/tp3/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="" vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/out/production/tp3/Cell.class b/out/production/tp3/Cell.class new file mode 100644 index 0000000000000000000000000000000000000000..f25b7df31b6ba9bd790deb4f3f8a3631cf724d96 Binary files /dev/null and b/out/production/tp3/Cell.class differ diff --git a/out/production/tp3/GameOfLife.class b/out/production/tp3/GameOfLife.class new file mode 100644 index 0000000000000000000000000000000000000000..8742b57ca730801bbd52eb0399299c60192f1843 Binary files /dev/null and b/out/production/tp3/GameOfLife.class differ diff --git a/out/production/tp3/GameOfLifeGUI.class b/out/production/tp3/GameOfLifeGUI.class new file mode 100644 index 0000000000000000000000000000000000000000..34b3b75fedc0ad93a1ffac7106e0a17cd2618c0c Binary files /dev/null and b/out/production/tp3/GameOfLifeGUI.class differ diff --git a/out/production/tp3/Grid.class b/out/production/tp3/Grid.class new file mode 100644 index 0000000000000000000000000000000000000000..056f19902a2199cee6fdae89286ef9e11ac6a3e7 Binary files /dev/null and b/out/production/tp3/Grid.class differ diff --git a/out/production/tp3/GridIterator.class b/out/production/tp3/GridIterator.class new file mode 100644 index 0000000000000000000000000000000000000000..87688b5b0ad1945fde68e7da4b49b7f88424ff2a Binary files /dev/null and b/out/production/tp3/GridIterator.class differ diff --git a/out/production/tp3/Main.class b/out/production/tp3/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..7431641eaa9ab52697a98ffecd095e91aa6346db Binary files /dev/null and b/out/production/tp3/Main.class differ diff --git a/out/production/tp3/tp3.iml b/out/production/tp3/tp3.iml new file mode 100644 index 0000000000000000000000000000000000000000..b107a2dd81165eaaf682ad3da030668b937fbb6c --- /dev/null +++ b/out/production/tp3/tp3.iml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/tp3.iml b/tp3.iml new file mode 100644 index 0000000000000000000000000000000000000000..b107a2dd81165eaaf682ad3da030668b937fbb6c --- /dev/null +++ b/tp3.iml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file