diff --git a/app/.gitignore (copy 1) b/app/.gitignore (copy 1)
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/app/.gitignore (copy 1)
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/app/build (copy 1).gradle b/app/build (copy 1).gradle
new file mode 100644
index 0000000..5313a38
--- /dev/null
+++ b/app/build (copy 1).gradle
@@ -0,0 +1,40 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ namespace 'com.example.jmastermind'
+ compileSdk 33
+
+ defaultConfig {
+ applicationId "com.example.jmastermind"
+ minSdk 19
+ targetSdk 33
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ buildToolsVersion '33.0.0'
+}
+
+dependencies {
+
+ implementation 'androidx.appcompat:appcompat:1.6.1'
+ implementation 'com.google.android.material:material:1.8.0'
+ implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
+}
\ No newline at end of file
diff --git a/app/proguard-rules (copy 1).pro b/app/proguard-rules (copy 1).pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/app/proguard-rules (copy 1).pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/example/jmastermind/ExampleInstrumentedTest (copy 1).java b/app/src/androidTest/java/com/example/jmastermind/ExampleInstrumentedTest (copy 1).java
new file mode 100644
index 0000000..9c546fc
--- /dev/null
+++ b/app/src/androidTest/java/com/example/jmastermind/ExampleInstrumentedTest (copy 1).java
@@ -0,0 +1,26 @@
+package com.example.jmastermind;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.example.jmastermind", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest (copy 1).xml b/app/src/main/AndroidManifest (copy 1).xml
new file mode 100644
index 0000000..0066848
--- /dev/null
+++ b/app/src/main/AndroidManifest (copy 1).xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jmastermind/Deck/Deck (copy 1).java b/app/src/main/java/com/example/jmastermind/Deck/Deck (copy 1).java
new file mode 100644
index 0000000..4c93001
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Deck/Deck (copy 1).java
@@ -0,0 +1,19 @@
+package com.example.jmastermind.Deck;
+
+import android.graphics.Color;
+
+import java.util.List;
+
+public interface Deck {
+ /**
+ * Recuperer la combinaison stockés dans la class
+ * @return La combinaison du deck
+ * */
+ public abstract List getDeck();
+
+ /**
+ * Retourne la combinaison sous forme de chaine de caractere
+ * @return Une facon personnaliser d'afficher la combinaison (debug)
+ * */
+ public abstract String displayComb();
+}
diff --git a/app/src/main/java/com/example/jmastermind/Deck/Deck.java b/app/src/main/java/com/example/jmastermind/Deck/Deck.java
index 47d4e86..4c93001 100644
--- a/app/src/main/java/com/example/jmastermind/Deck/Deck.java
+++ b/app/src/main/java/com/example/jmastermind/Deck/Deck.java
@@ -5,6 +5,15 @@ import android.graphics.Color;
import java.util.List;
public interface Deck {
+ /**
+ * Recuperer la combinaison stockés dans la class
+ * @return La combinaison du deck
+ * */
public abstract List getDeck();
+
+ /**
+ * Retourne la combinaison sous forme de chaine de caractere
+ * @return Une facon personnaliser d'afficher la combinaison (debug)
+ * */
public abstract String displayComb();
}
diff --git a/app/src/main/java/com/example/jmastermind/Deck/DeckCheck (copy 1).java b/app/src/main/java/com/example/jmastermind/Deck/DeckCheck (copy 1).java
new file mode 100644
index 0000000..c783dc5
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Deck/DeckCheck (copy 1).java
@@ -0,0 +1,109 @@
+package com.example.jmastermind.Deck;
+
+import android.graphics.Color;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+
+public class DeckCheck implements Deck {
+ private List deck;
+ private Deck lambda;
+ private Deck winner;
+
+ /**
+ * Permet de comparer une combinaison attaquante avec une combinaison gagnante
+ * @param lambda La combinaison attaquante
+ * @param winner La combinaison gagnante
+ * */
+ public DeckCheck(Deck lambda, Deck winner) {
+ this.deck = new LinkedList<>();
+ this.lambda = lambda;
+ this.winner = winner;
+ }
+
+ /**
+ * Lancement de la verification
+ * @return Le deck comprenant les pions de verification Noir et Blanc
+ * */
+ public Deck doCheck() {
+ this.deck = new LinkedList<>();
+ List winner = this.winner.getDeck();
+ List lambda = this.lambda.getDeck();
+
+ for(int i = 0; i <= winner.size()-1; i++) {
+ Integer win = winner.get(i);
+ Integer lam = lambda.get(i);
+
+ if(Objects.equals(win, lam)) {
+ this.deck.add(Color.BLACK);
+ } else {
+ if(winner.contains(lam)) {
+ this.deck.add(Color.WHITE);
+ } else {
+ this.deck.add(Color.GRAY);
+ }
+ }
+ }
+
+ Deck check = new DeckLambda(
+ this.deck.get(0),
+ this.deck.get(1),
+ this.deck.get(2),
+ this.deck.get(3)
+ );
+
+ return check;
+ }
+
+ @Override
+ public List getDeck() {
+ return this.deck;
+ }
+
+ @Override
+ public String displayComb() {
+ StringBuilder sb = new StringBuilder();
+
+ for(int i = 0; i <= this.deck.size()-1; i++) {
+ switch(this.deck.get(i)) {
+ case Color.BLACK: {
+ sb.append("Noir").append(", ");
+ break;
+ }
+
+ case Color.WHITE: {
+ sb.append("Blanc").append(", ");
+ break;
+ }
+
+ case Color.GRAY: {
+ sb.append("Gris").append(", ");
+ break;
+ }
+
+ case Color.GREEN: {
+ sb.append("Vert").append(", ");
+ break;
+ }
+
+ case Color.RED: {
+ sb.append("Rouge").append(", ");
+ break;
+ }
+
+ case Color.YELLOW: {
+ sb.append("Jaune").append(", ");
+ break;
+ }
+
+ case Color.BLUE: {
+ sb.append("Bleu").append(", ");
+ break;
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Deck/DeckCheck.java b/app/src/main/java/com/example/jmastermind/Deck/DeckCheck.java
index 85884a2..c783dc5 100644
--- a/app/src/main/java/com/example/jmastermind/Deck/DeckCheck.java
+++ b/app/src/main/java/com/example/jmastermind/Deck/DeckCheck.java
@@ -11,12 +11,21 @@ public class DeckCheck implements Deck {
private Deck lambda;
private Deck winner;
+ /**
+ * Permet de comparer une combinaison attaquante avec une combinaison gagnante
+ * @param lambda La combinaison attaquante
+ * @param winner La combinaison gagnante
+ * */
public DeckCheck(Deck lambda, Deck winner) {
this.deck = new LinkedList<>();
this.lambda = lambda;
this.winner = winner;
}
+ /**
+ * Lancement de la verification
+ * @return Le deck comprenant les pions de verification Noir et Blanc
+ * */
public Deck doCheck() {
this.deck = new LinkedList<>();
List winner = this.winner.getDeck();
diff --git a/app/src/main/java/com/example/jmastermind/Deck/DeckLambda (copy 1).java b/app/src/main/java/com/example/jmastermind/Deck/DeckLambda (copy 1).java
new file mode 100644
index 0000000..2e67b7a
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Deck/DeckLambda (copy 1).java
@@ -0,0 +1,75 @@
+package com.example.jmastermind.Deck;
+
+import android.graphics.Color;
+import java.util.LinkedList;
+import java.util.List;
+
+public class DeckLambda implements Deck{
+ List deck;
+
+ /**
+ * Composition de la combinaison attaquante
+ * @param c1 Couleur en int du Pion n1
+ * @param c2 Couleur en int du Pion n2
+ * @param c3 Couleur en int du Pion n3
+ * @param c4 Couleur en int du Pion n4
+ * */
+ public DeckLambda(Integer c1, Integer c2, Integer c3, Integer c4) {
+ this.deck = new LinkedList<>();
+ this.deck.add(c1);
+ this.deck.add(c2);
+ this.deck.add(c3);
+ this.deck.add(c4);
+ }
+
+ @Override
+ public List getDeck() {
+ return this.deck;
+ }
+
+ @Override
+ public String displayComb() {
+ StringBuilder sb = new StringBuilder();
+
+ for(int i = 0; i <= this.deck.size()-1; i++) {
+ switch(this.deck.get(i)) {
+ case Color.BLACK: {
+ sb.append("Noir").append(", ");
+ break;
+ }
+
+ case Color.WHITE: {
+ sb.append("Blanc").append(", ");
+ break;
+ }
+
+ case Color.GREEN: {
+ sb.append("Vert").append(", ");
+ break;
+ }
+
+ case Color.RED: {
+ sb.append("Rouge").append(", ");
+ break;
+ }
+
+ case Color.YELLOW: {
+ sb.append("Jaune").append(", ");
+ break;
+ }
+
+ case Color.BLUE: {
+ sb.append("Bleu").append(", ");
+ break;
+ }
+
+ case Color.GRAY: {
+ sb.append("Gris").append(", ");
+ break;
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Deck/DeckLambda.java b/app/src/main/java/com/example/jmastermind/Deck/DeckLambda.java
index 76e8101..2e67b7a 100644
--- a/app/src/main/java/com/example/jmastermind/Deck/DeckLambda.java
+++ b/app/src/main/java/com/example/jmastermind/Deck/DeckLambda.java
@@ -7,6 +7,13 @@ import java.util.List;
public class DeckLambda implements Deck{
List deck;
+ /**
+ * Composition de la combinaison attaquante
+ * @param c1 Couleur en int du Pion n1
+ * @param c2 Couleur en int du Pion n2
+ * @param c3 Couleur en int du Pion n3
+ * @param c4 Couleur en int du Pion n4
+ * */
public DeckLambda(Integer c1, Integer c2, Integer c3, Integer c4) {
this.deck = new LinkedList<>();
this.deck.add(c1);
diff --git a/app/src/main/java/com/example/jmastermind/Deck/DeckWinner (copy 1).java b/app/src/main/java/com/example/jmastermind/Deck/DeckWinner (copy 1).java
new file mode 100644
index 0000000..c066104
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Deck/DeckWinner (copy 1).java
@@ -0,0 +1,76 @@
+package com.example.jmastermind.Deck;
+
+import android.graphics.Color;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class DeckWinner implements Deck{
+ List deck;
+
+ /**
+ * Composition de la combinaison gagante
+ * @param c1 Couleur en int du Pion n1
+ * @param c2 Couleur en int du Pion n2
+ * @param c3 Couleur en int du Pion n3
+ * @param c4 Couleur en int du Pion n4
+ * */
+ public DeckWinner(Integer c1, Integer c2, Integer c3, Integer c4) {
+ this.deck = new LinkedList<>();
+ this.deck.add(c1);
+ this.deck.add(c2);
+ this.deck.add(c3);
+ this.deck.add(c4);
+ }
+
+ @Override
+ public List getDeck() {
+ return this.deck;
+ }
+
+ @Override
+ public String displayComb() {
+ StringBuilder sb = new StringBuilder();
+
+ for(int i = 0; i <= this.deck.size()-1; i++) {
+ switch(this.deck.get(i)) {
+ case Color.BLACK: {
+ sb.append("Noir").append(", ");
+ break;
+ }
+
+ case Color.WHITE: {
+ sb.append("Blanc").append(", ");
+ break;
+ }
+
+ case Color.GREEN: {
+ sb.append("Vert").append(", ");
+ break;
+ }
+
+ case Color.RED: {
+ sb.append("Rouge").append(", ");
+ break;
+ }
+
+ case Color.YELLOW: {
+ sb.append("Jaune").append(", ");
+ break;
+ }
+
+ case Color.BLUE: {
+ sb.append("Bleu").append(", ");
+ break;
+ }
+
+ case Color.GRAY: {
+ sb.append("Gris").append(", ");
+ break;
+ }
+ }
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Deck/DeckWinner.java b/app/src/main/java/com/example/jmastermind/Deck/DeckWinner.java
index dcbf111..c066104 100644
--- a/app/src/main/java/com/example/jmastermind/Deck/DeckWinner.java
+++ b/app/src/main/java/com/example/jmastermind/Deck/DeckWinner.java
@@ -8,6 +8,13 @@ import java.util.List;
public class DeckWinner implements Deck{
List deck;
+ /**
+ * Composition de la combinaison gagante
+ * @param c1 Couleur en int du Pion n1
+ * @param c2 Couleur en int du Pion n2
+ * @param c3 Couleur en int du Pion n3
+ * @param c4 Couleur en int du Pion n4
+ * */
public DeckWinner(Integer c1, Integer c2, Integer c3, Integer c4) {
this.deck = new LinkedList<>();
this.deck.add(c1);
diff --git a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent (copy 1).java b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent (copy 1).java
new file mode 100644
index 0000000..8aadb43
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent (copy 1).java
@@ -0,0 +1,175 @@
+package com.example.jmastermind.Events;
+
+import android.graphics.Color;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.jmastermind.Deck.Deck;
+import com.example.jmastermind.Deck.DeckCheck;
+import com.example.jmastermind.Deck.DeckLambda;
+import com.example.jmastermind.Game.Popup;
+import com.example.jmastermind.Geometrics.Circle;
+import com.example.jmastermind.R;
+
+import org.w3c.dom.Text;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class ColorSelectorEvent extends View implements View.OnClickListener {
+ private AppCompatActivity context;
+ /**
+ * [0] = x
+ * [1] = y
+ * */
+ private int[] coords;
+ private Deck winner;
+ private int tentative;
+
+ /**
+ * Evenement declanché lorsque le joueur selectionne une couleur
+ * @param context Le contexte de l'app
+ * @param winner La combinaison gagnante
+ * */
+ public ColorSelectorEvent(AppCompatActivity context, Deck winner) {
+ super(context);
+ this.context = context;
+ this.winner = winner;
+ this.coords = new int[]{1, 1};
+ this.tentative = 10;
+ }
+
+ /**
+ * Relier indirectement au bouton "Valider"
+ * Changer de ligne et lancer la verification des combinaisons
+ * */
+ public void goNext() {
+ List listOfColors = new LinkedList<>();
+
+ for(int i = 1; i <= 4; i++) {
+ int id = this.context.getResources()
+ .getIdentifier("normalCircle" + this.coords[0] + i, "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ listOfColors.add(c.getColor());
+ }
+
+ Deck lambda = new DeckLambda(
+ listOfColors.get(0),
+ listOfColors.get(1),
+ listOfColors.get(2),
+ listOfColors.get(3)
+ );
+
+ DeckCheck checker = new DeckCheck(lambda, this.winner);
+ Deck checkerPions = checker.doCheck();
+ List checkColors = checkerPions.getDeck();
+ int countOfBlack = 0;
+
+ for(int i = 1; i <= 4; i++) {
+ int id = this.context.getResources()
+ .getIdentifier("checkCircle" + this.coords[0] + i, "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ c.setColor(checkColors.get(i-1));
+
+ if(checkColors.get(i-1) == Color.BLACK) {
+ countOfBlack++;
+ }
+ }
+
+ if(countOfBlack == 4) {
+ String[] opts = new String[] {
+ "Rejouer",
+ "Voir votre jeu",
+ "Retourner au menu"
+ };
+
+ Popup popup = new Popup(this.context, opts, true, (10 - this.tentative + 1));
+ popup.show();
+ }
+
+ this.tentative--;
+
+ TextView tx = (TextView) this.context.findViewById(R.id.counter);
+ tx.setText("Tentative rest. \n" + this.tentative);
+ tx.invalidate();
+
+ this.coords[1] = 1;
+ this.coords[0]++;
+ }
+
+ /**
+ * Relier indirectement au bouton "Effacer"
+ * Permet d'effacer la combinaison non validé par le joueur
+ * */
+ public void resetCombi() {
+ for(int i = 1; i <= this.coords[1]; i++) {
+ int id = this.context.getResources()
+ .getIdentifier("normalCircle" + this.coords[0] + i, "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ c.setColor(Color.GRAY);
+ }
+
+ this.coords[1] = 1;
+ }
+
+ @Override
+ public void onClick(View view) {
+ int idOfClickedColor = view.getId();
+ Circle circleClicked = (Circle) this.context.findViewById(idOfClickedColor);
+ int colorChoosed = circleClicked.getColor();
+
+ int id = this.context.getResources()
+ .getIdentifier("normalCircle" + this.coords[0] + this.coords[1], "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ switch(colorChoosed) {
+ case Color.RED: {
+ c.setColor(Color.RED);
+ break;
+ }
+
+ case Color.GREEN: {
+ c.setColor(Color.GREEN);
+ break;
+ }
+
+ case Color.BLUE: {
+ c.setColor(Color.BLUE);
+ break;
+ }
+
+ case Color.YELLOW: {
+ c.setColor(Color.YELLOW);
+ break;
+ }
+
+ case Color.BLACK: {
+ c.setColor(Color.BLACK);
+ break;
+ }
+
+ case Color.WHITE: {
+ c.setColor(Color.WHITE);
+ break;
+ }
+
+ case Color.GRAY: {
+ c.setColor(Color.GRAY);
+ break;
+ }
+
+ default: {
+ break;
+ }
+ }
+
+ if(this.coords[1] < 4) {
+ this.coords[1]++;
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java
index e1ee091..8aadb43 100644
--- a/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java
+++ b/app/src/main/java/com/example/jmastermind/Events/ColorSelectorEvent.java
@@ -28,6 +28,11 @@ public class ColorSelectorEvent extends View implements View.OnClickListener {
private Deck winner;
private int tentative;
+ /**
+ * Evenement declanché lorsque le joueur selectionne une couleur
+ * @param context Le contexte de l'app
+ * @param winner La combinaison gagnante
+ * */
public ColorSelectorEvent(AppCompatActivity context, Deck winner) {
super(context);
this.context = context;
@@ -36,6 +41,82 @@ public class ColorSelectorEvent extends View implements View.OnClickListener {
this.tentative = 10;
}
+ /**
+ * Relier indirectement au bouton "Valider"
+ * Changer de ligne et lancer la verification des combinaisons
+ * */
+ public void goNext() {
+ List listOfColors = new LinkedList<>();
+
+ for(int i = 1; i <= 4; i++) {
+ int id = this.context.getResources()
+ .getIdentifier("normalCircle" + this.coords[0] + i, "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ listOfColors.add(c.getColor());
+ }
+
+ Deck lambda = new DeckLambda(
+ listOfColors.get(0),
+ listOfColors.get(1),
+ listOfColors.get(2),
+ listOfColors.get(3)
+ );
+
+ DeckCheck checker = new DeckCheck(lambda, this.winner);
+ Deck checkerPions = checker.doCheck();
+ List checkColors = checkerPions.getDeck();
+ int countOfBlack = 0;
+
+ for(int i = 1; i <= 4; i++) {
+ int id = this.context.getResources()
+ .getIdentifier("checkCircle" + this.coords[0] + i, "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ c.setColor(checkColors.get(i-1));
+
+ if(checkColors.get(i-1) == Color.BLACK) {
+ countOfBlack++;
+ }
+ }
+
+ if(countOfBlack == 4) {
+ String[] opts = new String[] {
+ "Rejouer",
+ "Voir votre jeu",
+ "Retourner au menu"
+ };
+
+ Popup popup = new Popup(this.context, opts, true, (10 - this.tentative + 1));
+ popup.show();
+ }
+
+ this.tentative--;
+
+ TextView tx = (TextView) this.context.findViewById(R.id.counter);
+ tx.setText("Tentative rest. \n" + this.tentative);
+ tx.invalidate();
+
+ this.coords[1] = 1;
+ this.coords[0]++;
+ }
+
+ /**
+ * Relier indirectement au bouton "Effacer"
+ * Permet d'effacer la combinaison non validé par le joueur
+ * */
+ public void resetCombi() {
+ for(int i = 1; i <= this.coords[1]; i++) {
+ int id = this.context.getResources()
+ .getIdentifier("normalCircle" + this.coords[0] + i, "id", this.context.getPackageName());
+ Circle c = this.context.findViewById(id);
+
+ c.setColor(Color.GRAY);
+ }
+
+ this.coords[1] = 1;
+ }
+
@Override
public void onClick(View view) {
int idOfClickedColor = view.getId();
@@ -91,72 +172,4 @@ public class ColorSelectorEvent extends View implements View.OnClickListener {
this.coords[1]++;
}
}
-
- public void goNext() {
- List listOfColors = new LinkedList<>();
-
- for(int i = 1; i <= 4; i++) {
- int id = this.context.getResources()
- .getIdentifier("normalCircle" + this.coords[0] + i, "id", this.context.getPackageName());
- Circle c = this.context.findViewById(id);
-
- listOfColors.add(c.getColor());
- }
-
- Deck lambda = new DeckLambda(
- listOfColors.get(0),
- listOfColors.get(1),
- listOfColors.get(2),
- listOfColors.get(3)
- );
-
- DeckCheck checker = new DeckCheck(lambda, this.winner);
- Deck checkerPions = checker.doCheck();
- List checkColors = checkerPions.getDeck();
- int countOfBlack = 0;
-
- for(int i = 1; i <= 4; i++) {
- int id = this.context.getResources()
- .getIdentifier("checkCircle" + this.coords[0] + i, "id", this.context.getPackageName());
- Circle c = this.context.findViewById(id);
-
- c.setColor(checkColors.get(i-1));
-
- if(checkColors.get(i-1) == Color.BLACK) {
- countOfBlack++;
- }
- }
-
- if(countOfBlack == 4) {
- String[] opts = new String[] {
- "Rejouer",
- "Voir votre jeu",
- "Retourner au menu"
- };
-
- Popup popup = new Popup(this.context, opts, true, (10 - this.tentative + 1));
- popup.show();
- }
-
- this.tentative--;
-
- TextView tx = (TextView) this.context.findViewById(R.id.counter);
- tx.setText("Tentative rest. \n" + this.tentative);
- tx.invalidate();
-
- this.coords[1] = 1;
- this.coords[0]++;
- }
-
- public void resetCombi() {
- for(int i = 1; i <= this.coords[1]; i++) {
- int id = this.context.getResources()
- .getIdentifier("normalCircle" + this.coords[0] + i, "id", this.context.getPackageName());
- Circle c = this.context.findViewById(id);
-
- c.setColor(Color.GRAY);
- }
-
- this.coords[1] = 1;
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jmastermind/Events/ControlEvent (copy 1).java b/app/src/main/java/com/example/jmastermind/Events/ControlEvent (copy 1).java
new file mode 100644
index 0000000..0239b11
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Events/ControlEvent (copy 1).java
@@ -0,0 +1,38 @@
+package com.example.jmastermind.Events;
+
+import android.content.Context;
+import android.view.View;
+import android.widget.Button;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.jmastermind.Game.Controller;
+
+public class ControlEvent extends View implements View.OnClickListener {
+ private final AppCompatActivity context;
+ private Controller controller;
+
+ /**
+ * Event relier aux boutons "Valider" et "Effacer"
+ * @param context Le context
+ * @param controller Le controller du jeu
+ * */
+ public ControlEvent(AppCompatActivity context, Controller controller) {
+ super(context);
+ this.context = context;
+ this.controller = controller;
+ }
+
+ @Override
+ public void onClick(View view) {
+ int idOfButton = view.getId();
+ Button btnClicked = (Button) this.context.findViewById(idOfButton);
+ CharSequence text = btnClicked.getText();
+
+ if ("Valider".equals(text)) {
+ this.controller.viewValidate();
+ } else if ("Effacer".equals(text)) {
+ this.controller.viewReset();
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Events/ControlEvent.java b/app/src/main/java/com/example/jmastermind/Events/ControlEvent.java
index 2801953..0239b11 100644
--- a/app/src/main/java/com/example/jmastermind/Events/ControlEvent.java
+++ b/app/src/main/java/com/example/jmastermind/Events/ControlEvent.java
@@ -12,6 +12,11 @@ public class ControlEvent extends View implements View.OnClickListener {
private final AppCompatActivity context;
private Controller controller;
+ /**
+ * Event relier aux boutons "Valider" et "Effacer"
+ * @param context Le context
+ * @param controller Le controller du jeu
+ * */
public ControlEvent(AppCompatActivity context, Controller controller) {
super(context);
this.context = context;
diff --git a/app/src/main/java/com/example/jmastermind/Events/MenuEvent (copy 1).java b/app/src/main/java/com/example/jmastermind/Events/MenuEvent (copy 1).java
new file mode 100644
index 0000000..84c79af
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Events/MenuEvent (copy 1).java
@@ -0,0 +1,26 @@
+package com.example.jmastermind.Events;
+
+import android.content.Intent;
+import android.view.View;
+import androidx.appcompat.app.AppCompatActivity;
+
+public class MenuEvent implements View.OnClickListener {
+ private Class option;
+ private AppCompatActivity ac;
+
+ /**
+ * Event lié au menu de depart
+ * @param ac Le contexte
+ * @param option La class de l'activité a demarrer
+ * */
+ public MenuEvent(AppCompatActivity ac, Class option) {
+ this.ac = ac;
+ this.option = option;
+ }
+
+ @Override
+ public void onClick(View view) {
+ Intent i = new Intent(this.ac, this.option);
+ this.ac.startActivity(i);
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Events/MenuEvent.java b/app/src/main/java/com/example/jmastermind/Events/MenuEvent.java
index c5dd4a2..84c79af 100644
--- a/app/src/main/java/com/example/jmastermind/Events/MenuEvent.java
+++ b/app/src/main/java/com/example/jmastermind/Events/MenuEvent.java
@@ -8,6 +8,11 @@ public class MenuEvent implements View.OnClickListener {
private Class option;
private AppCompatActivity ac;
+ /**
+ * Event lié au menu de depart
+ * @param ac Le contexte
+ * @param option La class de l'activité a demarrer
+ * */
public MenuEvent(AppCompatActivity ac, Class option) {
this.ac = ac;
this.option = option;
diff --git a/app/src/main/java/com/example/jmastermind/Events/PopupEvent (copy 1).java b/app/src/main/java/com/example/jmastermind/Events/PopupEvent (copy 1).java
new file mode 100644
index 0000000..bb08000
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Events/PopupEvent (copy 1).java
@@ -0,0 +1,44 @@
+package com.example.jmastermind.Events;
+
+import android.content.DialogInterface;
+import android.content.Intent;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.jmastermind.Game.Popup;
+import com.example.jmastermind.Game.SoloGame;
+import com.example.jmastermind.MainActivity;
+
+public class PopupEvent implements DialogInterface.OnClickListener {
+ private AppCompatActivity context;
+
+ /**
+ * Event lié au popup de fin de partie
+ * @param context Le context
+ * */
+ public PopupEvent(AppCompatActivity context) {
+ this.context = context;
+ }
+
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ switch(i) {
+ case 0: {
+ Intent a = new Intent(this.context, SoloGame.class);
+ this.context.startActivity(a);
+ break;
+ }
+
+ case 1: {
+ dialogInterface.cancel();
+ break;
+ }
+
+ case 2: {
+ Intent c = new Intent(this.context, MainActivity.class);
+ this.context.startActivity(c);
+ break;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java b/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java
index 0cbd997..bb08000 100644
--- a/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java
+++ b/app/src/main/java/com/example/jmastermind/Events/PopupEvent.java
@@ -12,6 +12,10 @@ import com.example.jmastermind.MainActivity;
public class PopupEvent implements DialogInterface.OnClickListener {
private AppCompatActivity context;
+ /**
+ * Event lié au popup de fin de partie
+ * @param context Le context
+ * */
public PopupEvent(AppCompatActivity context) {
this.context = context;
}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Controller (copy 1).java b/app/src/main/java/com/example/jmastermind/Game/Controller (copy 1).java
new file mode 100644
index 0000000..509783d
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Game/Controller (copy 1).java
@@ -0,0 +1,63 @@
+package com.example.jmastermind.Game;
+
+import android.graphics.Color;
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.jmastermind.Deck.Deck;
+import com.example.jmastermind.Deck.DeckWinner;
+import com.example.jmastermind.Events.ColorSelectorEvent;
+import com.example.jmastermind.Events.ControlEvent;
+
+import java.util.Random;
+
+public class Controller {
+ private Vuew vuew;
+ private Model model;
+ private AppCompatActivity context;
+ private ColorSelectorEvent event;
+ private ControlEvent controlEvent;
+
+ /**
+ * Controlleur du jeu
+ * @param context Le contexte
+ * @param mode 0 Solo ou 1 multi
+ * */
+ public Controller(AppCompatActivity context, int mode) {
+ this.context = context;
+ this.controlEvent = new ControlEvent(this.context, this);
+
+ this.model = new Model(this.context);
+ this.model.init();
+
+ if(mode == 0) {
+ this.model.genWinner();
+ Deck winner = this.model.getWinner();
+ System.out.println(winner.displayComb());
+ this.event = new ColorSelectorEvent(this.context, winner);
+ }
+
+ this.vuew = new Vuew(
+ this.context,
+ this.model.getListOfNormalCircle(),
+ this.model.getListOfCheckCircle(),
+ this.event,
+ this.controlEvent
+ );
+
+ this.vuew.init();
+ }
+
+ /**
+ * Quand le joueur appuie sur "valider"
+ * */
+ public void viewValidate() {
+ this.event.goNext();
+ }
+
+ /**
+ * Quand le joueur appuie sur "effacer"
+ * */
+ public void viewReset() {
+ this.event.resetCombi();
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Controller.java b/app/src/main/java/com/example/jmastermind/Game/Controller.java
index 9c82bb5..509783d 100644
--- a/app/src/main/java/com/example/jmastermind/Game/Controller.java
+++ b/app/src/main/java/com/example/jmastermind/Game/Controller.java
@@ -17,6 +17,11 @@ public class Controller {
private ColorSelectorEvent event;
private ControlEvent controlEvent;
+ /**
+ * Controlleur du jeu
+ * @param context Le contexte
+ * @param mode 0 Solo ou 1 multi
+ * */
public Controller(AppCompatActivity context, int mode) {
this.context = context;
this.controlEvent = new ControlEvent(this.context, this);
@@ -42,10 +47,16 @@ public class Controller {
this.vuew.init();
}
+ /**
+ * Quand le joueur appuie sur "valider"
+ * */
public void viewValidate() {
this.event.goNext();
}
+ /**
+ * Quand le joueur appuie sur "effacer"
+ * */
public void viewReset() {
this.event.resetCombi();
}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Model (copy 1).java b/app/src/main/java/com/example/jmastermind/Game/Model (copy 1).java
new file mode 100644
index 0000000..888c9a3
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Game/Model (copy 1).java
@@ -0,0 +1,139 @@
+package com.example.jmastermind.Game;
+
+import android.graphics.Color;
+import android.view.View;
+import androidx.appcompat.app.AppCompatActivity;
+import com.example.jmastermind.Deck.DeckWinner;
+import com.example.jmastermind.Geometrics.Circle;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+public class Model extends View {
+ private List listOfNormalCircle;
+ private List listOfCheckCircle;
+ private DeckWinner winner;
+ private AppCompatActivity context;
+
+ /**
+ * Le model du jeu
+ * @param context Le contexte
+ * */
+ public Model(AppCompatActivity context) {
+ super(context);
+ this.context = context;
+ this.listOfNormalCircle = new LinkedList<>();
+ this.listOfCheckCircle = new LinkedList<>();
+ this.winner = null;
+ }
+
+ /**
+ * Genere une combinaison aleatoire
+ * */
+ public void genWinner() {
+ Integer[] color = new Integer[]{0, 0, 0, 0};
+
+ for(int i = 0; i <= 3; i++) {
+ Random rand = new Random();
+ int ran = rand.nextInt(6) + 1;
+
+ switch(ran) {
+ case 1: {
+ color[i] = Color.RED;
+ break;
+ }
+
+ case 2: {
+ color[i] = Color.YELLOW;
+ break;
+ }
+
+ case 3: {
+ color[i] = Color.BLUE;
+ break;
+ }
+
+ case 4: {
+ color[i] = Color.GREEN;
+ break;
+ }
+
+ case 5: {
+ color[i] = Color.WHITE;
+ break;
+ }
+
+ case 6: {
+ color[i] = Color.BLACK;
+ break;
+ }
+
+ case 7: {
+ color[i] = Color.GRAY;
+ break;
+ }
+
+ default: {
+ break;
+ }
+ }
+ }
+
+ this.winner = new DeckWinner(color[1], color[0], color[2], color[3]);
+ }
+
+ /**
+ * Recupere le deck gagant du jeu
+ * @return DeckWinner Le deck gagant du jeu
+ * */
+ public DeckWinner getWinner() {
+ return this.winner;
+ }
+
+ /**
+ * Demarrage du Model
+ * @return Si oui ou non ca a fonctionné
+ * */
+ public Boolean init() {
+ try {
+ for(int i = 1; i <= 10; i++) {
+ for(int j = 1; j <= 4; j++) {
+ int normalId = this.context.getResources().
+ getIdentifier("normalCircle" + i + j, "id", this.context.getPackageName());
+ Circle normal = this.context.findViewById(normalId);
+
+ int checkId = this.context.getResources()
+ .getIdentifier("checkCircle" + i + j, "id", this.context.getPackageName());
+ Circle check = this.context.findViewById(checkId);
+
+ this.listOfNormalCircle.add(normal);
+ this.listOfCheckCircle.add(check);
+ }
+ }
+
+ return true;
+ } catch(ArrayIndexOutOfBoundsException e) {
+ System.out.println("[!] Probleme lors de l'initiliation du model (ArrayIndexOutOfBoundsException).");
+ return false;
+ } catch(NullPointerException e) {
+ System.out.println("[!] Probleme lors de l'initiliation du model (NullPointerException).");
+ return false;
+ }
+ }
+
+ /**
+ * Recuperation des cercles normaux du jeu (id="normalCircleXY" du xml)
+ * @return La liste des references vers les cercles normaux
+ * */
+ public List getListOfNormalCircle() {
+ return this.listOfNormalCircle;
+ }
+
+ /**
+ * Recuperation des clercles de verification du jeu (noir et blanc) (id="checkCircleXY" du xml)
+ * @return La liste des references vers les cercles de verification
+ * */
+ public List getListOfCheckCircle() {
+ return this.listOfCheckCircle;
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Model.java b/app/src/main/java/com/example/jmastermind/Game/Model.java
index c9ef68d..888c9a3 100644
--- a/app/src/main/java/com/example/jmastermind/Game/Model.java
+++ b/app/src/main/java/com/example/jmastermind/Game/Model.java
@@ -15,6 +15,10 @@ public class Model extends View {
private DeckWinner winner;
private AppCompatActivity context;
+ /**
+ * Le model du jeu
+ * @param context Le contexte
+ * */
public Model(AppCompatActivity context) {
super(context);
this.context = context;
@@ -23,6 +27,9 @@ public class Model extends View {
this.winner = null;
}
+ /**
+ * Genere une combinaison aleatoire
+ * */
public void genWinner() {
Integer[] color = new Integer[]{0, 0, 0, 0};
@@ -75,10 +82,18 @@ public class Model extends View {
this.winner = new DeckWinner(color[1], color[0], color[2], color[3]);
}
+ /**
+ * Recupere le deck gagant du jeu
+ * @return DeckWinner Le deck gagant du jeu
+ * */
public DeckWinner getWinner() {
return this.winner;
}
+ /**
+ * Demarrage du Model
+ * @return Si oui ou non ca a fonctionné
+ * */
public Boolean init() {
try {
for(int i = 1; i <= 10; i++) {
@@ -106,10 +121,18 @@ public class Model extends View {
}
}
+ /**
+ * Recuperation des cercles normaux du jeu (id="normalCircleXY" du xml)
+ * @return La liste des references vers les cercles normaux
+ * */
public List getListOfNormalCircle() {
return this.listOfNormalCircle;
}
+ /**
+ * Recuperation des clercles de verification du jeu (noir et blanc) (id="checkCircleXY" du xml)
+ * @return La liste des references vers les cercles de verification
+ * */
public List getListOfCheckCircle() {
return this.listOfCheckCircle;
}
diff --git a/app/src/main/java/com/example/jmastermind/Game/MultiGame (copy 1).java b/app/src/main/java/com/example/jmastermind/Game/MultiGame (copy 1).java
new file mode 100644
index 0000000..a35374d
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Game/MultiGame (copy 1).java
@@ -0,0 +1,4 @@
+package com.example.jmastermind.Game;
+
+public class MultiGame {
+}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Popup (copy 1).java b/app/src/main/java/com/example/jmastermind/Game/Popup (copy 1).java
new file mode 100644
index 0000000..af80e4d
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Game/Popup (copy 1).java
@@ -0,0 +1,30 @@
+package com.example.jmastermind.Game;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+import com.example.jmastermind.Events.PopupEvent;
+
+public class Popup extends AlertDialog.Builder {
+ private AppCompatActivity context;
+
+ /**
+ * Affiche la popup de fin de jeu
+ * @param context Le context
+ * @param options La liste des options (rejouer, ...)
+ * @param isWinner Esceque le joueur a gagner la partie
+ * @param tentative Le nombre de tentatives
+ * */
+ public Popup(AppCompatActivity context, String[] options, Boolean isWinner, int tentative) {
+ super(context);
+
+ this.context = context;
+
+ if(isWinner) {
+ this.setTitle("Félicitation ! Vous avez gagner en : " + tentative + " coup(s).");
+ } else {
+ this.setTitle("Perdu !");
+ }
+
+ this.setItems(options, new PopupEvent(this.context));
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Popup.java b/app/src/main/java/com/example/jmastermind/Game/Popup.java
index 39cd605..af80e4d 100644
--- a/app/src/main/java/com/example/jmastermind/Game/Popup.java
+++ b/app/src/main/java/com/example/jmastermind/Game/Popup.java
@@ -7,6 +7,13 @@ import com.example.jmastermind.Events.PopupEvent;
public class Popup extends AlertDialog.Builder {
private AppCompatActivity context;
+ /**
+ * Affiche la popup de fin de jeu
+ * @param context Le context
+ * @param options La liste des options (rejouer, ...)
+ * @param isWinner Esceque le joueur a gagner la partie
+ * @param tentative Le nombre de tentatives
+ * */
public Popup(AppCompatActivity context, String[] options, Boolean isWinner, int tentative) {
super(context);
diff --git a/app/src/main/java/com/example/jmastermind/Game/SoloGame (copy 1).java b/app/src/main/java/com/example/jmastermind/Game/SoloGame (copy 1).java
new file mode 100644
index 0000000..c07a4c1
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Game/SoloGame (copy 1).java
@@ -0,0 +1,21 @@
+package com.example.jmastermind.Game;
+
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import com.example.jmastermind.R;
+
+public class SoloGame extends AppCompatActivity {
+
+ /**
+ * Le jeu mode SOLO
+ * */
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.game);
+
+ Controller controller = new Controller(this, 0);
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Game/SoloGame.java b/app/src/main/java/com/example/jmastermind/Game/SoloGame.java
index 54d9592..c07a4c1 100644
--- a/app/src/main/java/com/example/jmastermind/Game/SoloGame.java
+++ b/app/src/main/java/com/example/jmastermind/Game/SoloGame.java
@@ -7,6 +7,10 @@ import androidx.appcompat.app.AppCompatActivity;
import com.example.jmastermind.R;
public class SoloGame extends AppCompatActivity {
+
+ /**
+ * Le jeu mode SOLO
+ * */
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
diff --git a/app/src/main/java/com/example/jmastermind/Game/Vuew (copy 1).java b/app/src/main/java/com/example/jmastermind/Game/Vuew (copy 1).java
new file mode 100644
index 0000000..f56ca9d
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Game/Vuew (copy 1).java
@@ -0,0 +1,86 @@
+package com.example.jmastermind.Game;
+
+import android.graphics.Color;
+import android.widget.Button;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import com.example.jmastermind.Events.ColorSelectorEvent;
+import com.example.jmastermind.Events.ControlEvent;
+import com.example.jmastermind.Geometrics.Circle;
+import com.example.jmastermind.R;
+
+import java.util.List;
+
+public class Vuew {
+ private ColorSelectorEvent event;
+ private List normalCircle;
+ private List checkedCircle;
+ private AppCompatActivity context;
+ private ControlEvent controlEvent;
+
+ /**
+ * La vue du jeu
+ * @param context Le context
+ * @param normalCircle Les references vers les cercles normaux
+ * @param checkCircle Les references vers les cercles de verification
+ * @param event L'event de la selection de couleur
+ * @param controlEvent L'event vers les deux boutons Valider et Effacer
+ * */
+ public Vuew(AppCompatActivity context, List normalCircle, List checkCircle, ColorSelectorEvent event, ControlEvent controlEvent) {
+ this.context = context;
+ this.normalCircle = normalCircle;
+ this.checkedCircle = checkCircle;
+ this.event = event;
+ this.controlEvent = controlEvent;
+ }
+
+ /**
+ * Parametrage du plateau de jeu
+ * */
+ public Boolean init() {
+ try {
+ Circle yellow = (Circle) this.context.findViewById(R.id.yellow);
+ yellow.setColor(Color.YELLOW);
+ yellow.setOnClickListener(this.event);
+
+ Circle red = (Circle) this.context.findViewById(R.id.red);
+ red.setColor(Color.RED);
+ red.setOnClickListener(this.event);
+
+ Circle green = (Circle) this.context.findViewById(R.id.green);
+ green.setColor(Color.GREEN);
+ green.setOnClickListener(this.event);
+
+ Circle blue = (Circle) this.context.findViewById(R.id.blue);
+ blue.setColor(Color.BLUE);
+ blue.setOnClickListener(this.event);
+
+ Circle gray = (Circle) this.context.findViewById(R.id.gray);
+ gray.setColor(Color.GRAY);
+ gray.setOnClickListener(this.event);
+
+ Circle white = (Circle) this.context.findViewById(R.id.white);
+ white.setColor(Color.WHITE);
+ white.setOnClickListener(this.event);
+
+ Circle black = (Circle) this.context.findViewById(R.id.black);
+ black.setColor(Color.BLACK);
+ black.setOnClickListener(this.event);
+
+ Button validate = (Button) this.context.findViewById(R.id.validate);
+ validate.setOnClickListener(this.controlEvent);
+
+ Button reset = (Button) this.context.findViewById(R.id.reset);
+ reset.setOnClickListener(this.controlEvent);
+
+ return true;
+ } catch(NullPointerException e) {
+ System.out.println("[!] Probleme lors de l'initiliation de la vue (NullPointerException).");
+ return false;
+ } catch(ArrayIndexOutOfBoundsException e) {
+ System.out.println("[!] Probleme lors de l'initiliation de la vue (ArrayIndexOutOfBoundsException).");
+ return false;
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Game/Vuew.java b/app/src/main/java/com/example/jmastermind/Game/Vuew.java
index ff5b6e8..f56ca9d 100644
--- a/app/src/main/java/com/example/jmastermind/Game/Vuew.java
+++ b/app/src/main/java/com/example/jmastermind/Game/Vuew.java
@@ -19,6 +19,14 @@ public class Vuew {
private AppCompatActivity context;
private ControlEvent controlEvent;
+ /**
+ * La vue du jeu
+ * @param context Le context
+ * @param normalCircle Les references vers les cercles normaux
+ * @param checkCircle Les references vers les cercles de verification
+ * @param event L'event de la selection de couleur
+ * @param controlEvent L'event vers les deux boutons Valider et Effacer
+ * */
public Vuew(AppCompatActivity context, List normalCircle, List checkCircle, ColorSelectorEvent event, ControlEvent controlEvent) {
this.context = context;
this.normalCircle = normalCircle;
@@ -27,6 +35,9 @@ public class Vuew {
this.controlEvent = controlEvent;
}
+ /**
+ * Parametrage du plateau de jeu
+ * */
public Boolean init() {
try {
Circle yellow = (Circle) this.context.findViewById(R.id.yellow);
diff --git a/app/src/main/java/com/example/jmastermind/Geometrics/Circle (copy 1).java b/app/src/main/java/com/example/jmastermind/Geometrics/Circle (copy 1).java
new file mode 100644
index 0000000..2c9e4e1
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/Geometrics/Circle (copy 1).java
@@ -0,0 +1,55 @@
+package com.example.jmastermind.Geometrics;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.View;
+
+import androidx.annotation.Nullable;
+
+public class Circle extends View {
+ private Paint picasso;
+ private int color;
+
+ /**
+ * Les cercles du jeu "programmiser" en Java
+ * @param context Le context
+ * @param attrs Les attributs (notamment id)
+ * */
+ public Circle(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ this.color = Color.GRAY;
+ this.picasso = new Paint();
+ }
+
+ /**
+ * Recuperer la couleur du cercle
+ * @return La couleur du cercle en int
+ * */
+ public int getColor() {
+ return this.color;
+ }
+
+ /**
+ * Changer la couleur d'un cercle
+ * @param c La nouvelle couleur
+ * */
+ public void setColor(int c) {
+ this.color = c;
+ this.invalidate();
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ int centerX = getWidth() / 2;
+ int centerY = getHeight() / 2;
+ int radius = Math.min(centerX, centerY);
+
+ this.picasso.setColor(this.color);
+ canvas.drawCircle(centerX, centerY, radius, this.picasso);
+ }
+}
diff --git a/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java b/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java
index 51db376..2c9e4e1 100644
--- a/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java
+++ b/app/src/main/java/com/example/jmastermind/Geometrics/Circle.java
@@ -13,16 +13,29 @@ public class Circle extends View {
private Paint picasso;
private int color;
+ /**
+ * Les cercles du jeu "programmiser" en Java
+ * @param context Le context
+ * @param attrs Les attributs (notamment id)
+ * */
public Circle(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.color = Color.GRAY;
this.picasso = new Paint();
}
+ /**
+ * Recuperer la couleur du cercle
+ * @return La couleur du cercle en int
+ * */
public int getColor() {
return this.color;
}
+ /**
+ * Changer la couleur d'un cercle
+ * @param c La nouvelle couleur
+ * */
public void setColor(int c) {
this.color = c;
this.invalidate();
diff --git a/app/src/main/java/com/example/jmastermind/MainActivity (copy 1).java b/app/src/main/java/com/example/jmastermind/MainActivity (copy 1).java
new file mode 100644
index 0000000..92bc607
--- /dev/null
+++ b/app/src/main/java/com/example/jmastermind/MainActivity (copy 1).java
@@ -0,0 +1,22 @@
+package com.example.jmastermind;
+
+import androidx.appcompat.app.AppCompatActivity;
+import android.os.Bundle;
+import android.widget.Button;
+import com.example.jmastermind.Events.MenuEvent;
+import com.example.jmastermind.Game.*;
+
+public class MainActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.menu);
+
+ Button btnSoloGame = (Button) findViewById(R.id.robotselect);
+ btnSoloGame.setOnClickListener(new MenuEvent(this, SoloGame.class));
+
+ Button btnMultiGame = (Button) findViewById(R.id.jcjselect);
+ btnMultiGame.setOnClickListener(new MenuEvent(this, MultiGame.class));
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground (copy 1).xml b/app/src/main/res/drawable-v24/ic_launcher_foreground (copy 1).xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/app/src/main/res/drawable-v24/ic_launcher_foreground (copy 1).xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_launcher_background (copy 1).xml b/app/src/main/res/drawable/ic_launcher_background (copy 1).xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/app/src/main/res/drawable/ic_launcher_background (copy 1).xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/game (copy 1).xml b/app/src/main/res/layout/game (copy 1).xml
new file mode 100644
index 0000000..098313a
--- /dev/null
+++ b/app/src/main/res/layout/game (copy 1).xml
@@ -0,0 +1,869 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/menu (copy 1).xml b/app/src/main/res/layout/menu (copy 1).xml
new file mode 100644
index 0000000..e249086
--- /dev/null
+++ b/app/src/main/res/layout/menu (copy 1).xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher (copy 1).xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher (copy 1).xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher (copy 1).xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round (copy 1).xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round (copy 1).xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round (copy 1).xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v33/ic_launcher (copy 1).xml b/app/src/main/res/mipmap-anydpi-v33/ic_launcher (copy 1).xml
new file mode 100644
index 0000000..6f3b755
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v33/ic_launcher (copy 1).xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher (copy 1).webp b/app/src/main/res/mipmap-hdpi/ic_launcher (copy 1).webp
new file mode 100644
index 0000000..c209e78
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round (copy 1).webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round (copy 1).webp
new file mode 100644
index 0000000..b2dfe3d
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher (copy 1).webp b/app/src/main/res/mipmap-mdpi/ic_launcher (copy 1).webp
new file mode 100644
index 0000000..4f0f1d6
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round (copy 1).webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round (copy 1).webp
new file mode 100644
index 0000000..62b611d
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher (copy 1).webp b/app/src/main/res/mipmap-xhdpi/ic_launcher (copy 1).webp
new file mode 100644
index 0000000..948a307
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round (copy 1).webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round (copy 1).webp
new file mode 100644
index 0000000..1b9a695
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher (copy 1).webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher (copy 1).webp
new file mode 100644
index 0000000..28d4b77
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round (copy 1).webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round (copy 1).webp
new file mode 100644
index 0000000..9287f50
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher (copy 1).webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher (copy 1).webp
new file mode 100644
index 0000000..aa7d642
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher (copy 1).webp differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round (copy 1).webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round (copy 1).webp
new file mode 100644
index 0000000..9126ae3
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round (copy 1).webp differ
diff --git a/app/src/main/res/values-night/themes (copy 1).xml b/app/src/main/res/values-night/themes (copy 1).xml
new file mode 100644
index 0000000..8750f33
--- /dev/null
+++ b/app/src/main/res/values-night/themes (copy 1).xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors (copy 1).xml b/app/src/main/res/values/colors (copy 1).xml
new file mode 100644
index 0000000..f8c6127
--- /dev/null
+++ b/app/src/main/res/values/colors (copy 1).xml
@@ -0,0 +1,10 @@
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings (copy 1).xml b/app/src/main/res/values/strings (copy 1).xml
new file mode 100644
index 0000000..40b86b4
--- /dev/null
+++ b/app/src/main/res/values/strings (copy 1).xml
@@ -0,0 +1,3 @@
+
+ JMastermind
+
\ No newline at end of file
diff --git a/app/src/main/res/values/themes (copy 1).xml b/app/src/main/res/values/themes (copy 1).xml
new file mode 100644
index 0000000..143e270
--- /dev/null
+++ b/app/src/main/res/values/themes (copy 1).xml
@@ -0,0 +1,16 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/backup_rules (copy 1).xml b/app/src/main/res/xml/backup_rules (copy 1).xml
new file mode 100644
index 0000000..fa0f996
--- /dev/null
+++ b/app/src/main/res/xml/backup_rules (copy 1).xml
@@ -0,0 +1,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/data_extraction_rules (copy 1).xml b/app/src/main/res/xml/data_extraction_rules (copy 1).xml
new file mode 100644
index 0000000..9ee9997
--- /dev/null
+++ b/app/src/main/res/xml/data_extraction_rules (copy 1).xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/com/example/jmastermind/ExampleUnitTest (copy 1).java b/app/src/test/java/com/example/jmastermind/ExampleUnitTest (copy 1).java
new file mode 100644
index 0000000..496ae0f
--- /dev/null
+++ b/app/src/test/java/com/example/jmastermind/ExampleUnitTest (copy 1).java
@@ -0,0 +1,17 @@
+package com.example.jmastermind;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file