diff --git a/NetBeans Projects/mastermind/.idea/.gitignore b/NetBeans Projects/mastermind/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/NetBeans Projects/mastermind/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/NetBeans Projects/mastermind/.idea/misc.xml b/NetBeans Projects/mastermind/.idea/misc.xml
new file mode 100644
index 0000000..432b646
--- /dev/null
+++ b/NetBeans Projects/mastermind/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NetBeans Projects/mastermind/.idea/modules.xml b/NetBeans Projects/mastermind/.idea/modules.xml
new file mode 100644
index 0000000..23c527d
--- /dev/null
+++ b/NetBeans Projects/mastermind/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NetBeans Projects/mastermind/.idea/vcs.xml b/NetBeans Projects/mastermind/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/NetBeans Projects/mastermind/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NetBeans Projects/mastermind/mastermind.iml b/NetBeans Projects/mastermind/mastermind.iml
new file mode 100644
index 0000000..e5d2daf
--- /dev/null
+++ b/NetBeans Projects/mastermind/mastermind.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/NetBeans Projects/mastermind/src/mastermind/MasterMind.java b/NetBeans Projects/mastermind/src/mastermind/MasterMind.java
new file mode 100644
index 0000000..8d1f0fe
--- /dev/null
+++ b/NetBeans Projects/mastermind/src/mastermind/MasterMind.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2023 Giacomo Radaelli
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package mastermind;
+
+import java.util.ArrayList;
+import java.util.Random;
+
+/**
+ * Classe che simula il gioco Mastermind
+ * @author radaelli11353
+ */
+public class MasterMind {
+ ArrayList lettereValide;
+ ArrayList segreto;
+ int tentativi;
+
+ public MasterMind() {
+ lettereValide = new ArrayList<>(6);
+ lettereValide.add('R');
+ lettereValide.add('V');
+ lettereValide.add('G');
+ lettereValide.add('B');
+ lettereValide.add('N');
+ lettereValide.add('M');
+ tentativi = 0;
+ segreto = genera();
+ System.out.println(segreto);
+ }
+
+ static private ArrayList genera() {
+ Random gen = new Random();
+ ArrayList segreto = new ArrayList<>();
+
+
+ for(int i = 0; i < 4; i++) {
+ int num = gen.nextInt(5);
+
+ switch (num) {
+ case 0: segreto.add('R'); break;
+ case 1: segreto.add('V'); break;
+ case 2: segreto.add('G'); break;
+ case 3: segreto.add('B'); break;
+ case 4: segreto.add('N'); break;
+ default: segreto.add('M'); break;
+ }
+ }
+
+ return segreto;
+ }
+
+ public int[] muovi(String originale) {
+ if(tentativi >= 10) throw new IllegalStateException("Hai esaurito i tentativi");
+ if(originale.length() != 4) throw new IllegalArgumentException("Devi inserire quattro caratteri");
+ ArrayList utente = new ArrayList<>(4);
+
+ for(int i = 0; i < 4; i++) {
+ if(!lettereValide.contains(originale.charAt(i))) throw new IllegalArgumentException("I colori inseriti non sono validi");
+ utente.add(originale.charAt(i));
+ }
+
+ int pgiusto = 0, psbagliato = 0;
+
+ for (int i = 0; i < 4; i++) {
+ if(utente.indexOf(segreto.get(i)) == -1) {
+
+ } else if(utente.indexOf(segreto.get(i)) == i) {
+ pgiusto++;
+ utente.set(i, Character.MIN_VALUE);
+ } else {
+ psbagliato++;
+ }
+ }
+
+ return new int[] {pgiusto, psbagliato};
+ }
+
+ public boolean hasNext() {
+ return tentativi < 9;
+ }
+}
diff --git a/NetBeans Projects/mastermind/src/mastermind/Tester.java b/NetBeans Projects/mastermind/src/mastermind/Tester.java
new file mode 100644
index 0000000..95a20c1
--- /dev/null
+++ b/NetBeans Projects/mastermind/src/mastermind/Tester.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2023 Giacomo Radaelli
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package mastermind;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author radaelli11353
+ */
+public class Tester {
+ public static void main(String[] args) {
+ MasterMind test = new MasterMind();
+ Scanner in = new Scanner(System.in);
+ int tentativi = 0;
+ boolean vinto = false;
+
+ while(test.hasNext() && !vinto) {
+ String parola = in.nextLine().toUpperCase().replace(" ","");
+
+ int[] risultato = test.muovi(parola);
+ tentativi++;
+ if(risultato[0] == 4) {
+ System.out.println("HAI VINTO!");
+ vinto = true;
+ break;
+ }
+
+ if(tentativi == 10) {
+ System.out.println("Hai perso");
+ return;
+ }
+ System.out.printf("%d %d <-- Risultato del %d tentativo", risultato[0], risultato[1], tentativi);
+
+ }
+ }
+
+
+}