diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-03-26 19:27:18 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-03-26 19:27:18 +0100 |
| commit | 7167b4341ef290d56fb96e2af10883a4b925d83b (patch) | |
| tree | 1eb1b9e5ab82ddd89540e68d6b22ae69514575c6 /robottino/all_versions | |
| download | ancient-projects-master.tar.gz ancient-projects-master.zip | |
Diffstat (limited to 'robottino/all_versions')
153 files changed, 5910 insertions, 0 deletions
diff --git a/robottino/all_versions/Changelog.txt b/robottino/all_versions/Changelog.txt new file mode 100755 index 0000000..575e94b --- /dev/null +++ b/robottino/all_versions/Changelog.txt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | v1.0: La prima versione. | ||
| 2 | |||
| 3 | v2.0: Aggiunte funzionalità crea/rinomina/cambia robottino. | ||
| 4 | |||
| 5 | v2.1: Sostituiti gli array con i Vector. Aggiunta funzionalità elimina robottino. | ||
| 6 | |||
| 7 | v2.2: Agiunta la finestra. | ||
| 8 | |||
| 9 | v2.3: Aggiunte le funzioni per dare comandi attraverso la finestra. | ||
| 10 | |||
| 11 | Non è più possibile dare comandi a linea di comando. | ||
| 12 | v3.0: Aggiunta delle immagini. | ||
| 13 | |||
| 14 | v4.0: Cambiata la grafica da awt a swing. | ||
| 15 | Finalmente ad ogni comando il robottino si muove e non è più presente | ||
| 16 | l'output a riga di comando. Molte delle vecchie funzioni devono essere re-implementate. | ||
| 17 | |||
| 18 | v4.0.1: Fixato il bug di sfarfallio - immagini tagliate. | ||
| 19 | |||
| 20 | v4.1: Re-implementate tute le vecchie funzioni. | ||
diff --git a/robottino/all_versions/v1.0/Esegui.bat b/robottino/all_versions/v1.0/Esegui.bat new file mode 100755 index 0000000..1eb0b2e --- /dev/null +++ b/robottino/all_versions/v1.0/Esegui.bat | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | cd ./bin | ||
| 2 | java Robottino | ||
diff --git a/robottino/all_versions/v1.0/Esegui.sh b/robottino/all_versions/v1.0/Esegui.sh new file mode 100755 index 0000000..1eb0b2e --- /dev/null +++ b/robottino/all_versions/v1.0/Esegui.sh | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | cd ./bin | ||
| 2 | java Robottino | ||
diff --git a/robottino/all_versions/v1.0/Readme.txt b/robottino/all_versions/v1.0/Readme.txt new file mode 100755 index 0000000..52d532c --- /dev/null +++ b/robottino/all_versions/v1.0/Readme.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Il programma necessita della JVM (Java Virtual Machine) per funzionare correttamente | ||
| 2 | |||
| 3 | Se si usano sistemi Windows aprire il file Esegui.bat | ||
| 4 | Se si usano sistemi Unix dare i permessi necessari ed eseguire il file Esegui.sh | ||
| 5 | Se si usano altri sistemi aprire una shell e digitare i comandi | ||
| 6 | |||
| 7 | cd <percorsoFile>/bin | ||
| 8 | java Robottino | ||
| 9 | |||
| 10 | dove percorsoFile è il percorso di questo file. | ||
diff --git a/robottino/all_versions/v1.0/bin/PartiDelRobot.class b/robottino/all_versions/v1.0/bin/PartiDelRobot.class new file mode 100755 index 0000000..a7d1f7e --- /dev/null +++ b/robottino/all_versions/v1.0/bin/PartiDelRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v1.0/bin/Robottino.class b/robottino/all_versions/v1.0/bin/Robottino.class new file mode 100755 index 0000000..770ae6b --- /dev/null +++ b/robottino/all_versions/v1.0/bin/Robottino.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v1.0/src/PartiDelRobot.java b/robottino/all_versions/v1.0/src/PartiDelRobot.java new file mode 100755 index 0000000..078f7a0 --- /dev/null +++ b/robottino/all_versions/v1.0/src/PartiDelRobot.java | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | class PartiDelRobot { | ||
| 2 | PartiDelRobot() { }; | ||
| 3 | PartiDelRobot(boolean b, String s) { | ||
| 4 | this.stringaParte = s; | ||
| 5 | this.statoParte = b; | ||
| 6 | } | ||
| 7 | public String stringaParte; | ||
| 8 | public boolean statoParte; | ||
| 9 | } | ||
diff --git a/robottino/all_versions/v1.0/src/Robottino.java b/robottino/all_versions/v1.0/src/Robottino.java new file mode 100755 index 0000000..e155613 --- /dev/null +++ b/robottino/all_versions/v1.0/src/Robottino.java | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | import java.util.Scanner; | ||
| 2 | class Robottino extends PartiDelRobot { | ||
| 3 | public static void main(String argv[]) { | ||
| 4 | Robottino robot = new Robottino(); | ||
| 5 | PartiDelRobot pdr[] = { new PartiDelRobot (false, "il braccio sinistro alzato"), | ||
| 6 | new PartiDelRobot (false, "il braccio destro alzato"), | ||
| 7 | new PartiDelRobot (false, "la gamba sinistra alzata"), | ||
| 8 | new PartiDelRobot (false, "la gamba destra alzata") }; | ||
| 9 | Scanner sc = new Scanner(System.in); | ||
| 10 | String comando; | ||
| 11 | String nomeRobot[] = { "" }; | ||
| 12 | System.out.println("**********************************************"); | ||
| 13 | System.out.println("**********************************************"); | ||
| 14 | System.out.println("*************Programma interattivo************"); | ||
| 15 | System.out.println("**********************************************"); | ||
| 16 | System.out.println("***Software realizzato da Sebastiano Tronto***"); | ||
| 17 | System.out.println("**********************************************"); | ||
| 18 | System.out.println("**********************************************"); | ||
| 19 | System.out.println("Questo programma simula un robot al quale ven-"); | ||
| 20 | System.out.println("gono assegnati ordini tramite comandi, simil-" ); | ||
| 21 | System.out.println("mente a quanto bisognava fare con i computer " ); | ||
| 22 | System.out.println("alcuni anni fa." ); | ||
| 23 | System.out.println("Dato che all'epoca i comandi che dovevano es-" ); | ||
| 24 | System.out.println("sere dati erano (e sono tutt'ora) in similin-" ); | ||
| 25 | System.out.println("glese, ho cercato di mantenerli tali." ); | ||
| 26 | System.out.println("Il programma non fa distinzioni tra lettere" ); | ||
| 27 | System.out.println("maiuscole o minuscole." ); | ||
| 28 | System.out.println("" ); | ||
| 29 | System.out.println("Digita un comando e premi invio" ); | ||
| 30 | System.out.println("l = legenda comandi" ); | ||
| 31 | do { | ||
| 32 | comando = sc.nextLine(); | ||
| 33 | System.out.println ("Siamo spiacenti, ma per motivi tecnici non sono in grado di visualizzare l'immagine del robot."); | ||
| 34 | System.out.println (robot.Azioni(comando, nomeRobot, pdr)); | ||
| 35 | } while ( !(comando.equalsIgnoreCase("exit")) ); | ||
| 36 | } | ||
| 37 | String Azioni(String comando, String nomeRobot[], PartiDelRobot pdr[]) { | ||
| 38 | Scanner sc2 = new Scanner(System.in); | ||
| 39 | int contatore = 0; | ||
| 40 | String stat[] = {"", "", "", ""}; | ||
| 41 | String Return = "Errore - si consiglia di picchiare il programmatore"; | ||
| 42 | if (comando.equalsIgnoreCase("leftarmmove")) | ||
| 43 | pdr[0].statoParte = !pdr[0].statoParte; | ||
| 44 | else if (comando.equalsIgnoreCase("rightarmmove")) | ||
| 45 | pdr[1].statoParte = !pdr[1].statoParte; | ||
| 46 | else if (comando.equalsIgnoreCase("leftlegmove")) | ||
| 47 | pdr[2].statoParte = !pdr[2].statoParte; | ||
| 48 | else if (comando.equalsIgnoreCase("rightlegmove")) | ||
| 49 | pdr[3].statoParte = !pdr[3].statoParte; | ||
| 50 | else if (comando.equalsIgnoreCase("leftarmon")) | ||
| 51 | pdr[0].statoParte = true; | ||
| 52 | else if (comando.equalsIgnoreCase("rightarmon")) | ||
| 53 | pdr[1].statoParte = true; | ||
| 54 | else if (comando.equalsIgnoreCase("leftlegon")) | ||
| 55 | pdr[2].statoParte = true; | ||
| 56 | else if (comando.equalsIgnoreCase("rightlegon")) | ||
| 57 | pdr[3].statoParte = true; | ||
| 58 | else if (comando.equalsIgnoreCase("leftarmoff")) | ||
| 59 | pdr[0].statoParte = false; | ||
| 60 | else if (comando.equalsIgnoreCase("rightarmoff")) | ||
| 61 | pdr[1].statoParte = false; | ||
| 62 | else if (comando.equalsIgnoreCase("leftlegoff")) | ||
| 63 | pdr[2].statoParte = false; | ||
| 64 | else if (comando.equalsIgnoreCase("rightlegoff")) | ||
| 65 | pdr[3].statoParte = false; | ||
| 66 | else if (comando.equalsIgnoreCase("exploud")) { | ||
| 67 | System.out.println ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot[0] + "! Aspetta che te ne faccio un altro"); | ||
| 68 | System.out.println ("..."); | ||
| 69 | for (int i = 0; i < pdr.length; i++) { | ||
| 70 | pdr[i].statoParte = false; | ||
| 71 | } | ||
| 72 | nomeRobot[0] = ""; | ||
| 73 | return "Fatto, puoi continuare a giocare"; | ||
| 74 | } | ||
| 75 | else if (comando.equalsIgnoreCase("bier")) { | ||
| 76 | System.out.println ("Il robottino " + nomeRobot[0] + "sta trangugiando una birra..."); | ||
| 77 | System.out.println ("Buurrrrrrrrp!"); | ||
| 78 | return "La birra analcolica fa schifo!"; | ||
| 79 | } | ||
| 80 | else if (comando.equalsIgnoreCase("rename")) { | ||
| 81 | System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot[0]); | ||
| 82 | System.out.println ("Digita il nuovo nome e premi invio per coninuare"); | ||
| 83 | nomeRobot[0] = sc2.nextLine(); | ||
| 84 | if (!(nomeRobot[0].equalsIgnoreCase(""))) | ||
| 85 | nomeRobot[0] += " "; | ||
| 86 | return "Ora il robottino si chiama " + nomeRobot[0]; | ||
| 87 | } | ||
| 88 | else if (comando.equalsIgnoreCase("porky")) { | ||
| 89 | System.out.println ("Porky è un grande"); | ||
| 90 | System.out.println ("Per maggiori informazioni visita il sito"); | ||
| 91 | return "http://kakati.forumfree.net/"; | ||
| 92 | } | ||
| 93 | else if (comando.equalsIgnoreCase("xxx")) { | ||
| 94 | System.out.println ("Il robottino " + nomeRobot[0] + "ha incontrato una bella robottina..."); | ||
| 95 | return "*Censura*"; | ||
| 96 | } | ||
| 97 | else if (comando.equalsIgnoreCase("l")) { | ||
| 98 | System.out.println ("Legenda comandi"); | ||
| 99 | System.out.println (""); | ||
| 100 | System.out.println ("LeftArmMove: cambia la posizione corrente del braccio sinistro del robot"); | ||
| 101 | System.out.println ("RightArmMove: cambia la posizione corrente del braccio destro del robot"); | ||
| 102 | System.out.println ("LeftLegMove: cambia la posizione corrente della gamba sinistra del robot"); | ||
| 103 | System.out.println ("RightLegMove: cambia la posizione corrente della gamba destra del robot"); | ||
| 104 | System.out.println ("LeftArmOn: se il braccio sinistro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 105 | System.out.println ("RightArmOn: se il braccio destro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 106 | System.out.println ("LeftLegOn: se la gamba sinistra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 107 | System.out.println ("RightLegOn: se la gamba destra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 108 | System.out.println ("LeftArmOff: se il braccio sinistro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 109 | System.out.println ("RightArmOff: se il braccio destro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 110 | System.out.println ("LeftLegOff: se la gamba sinistra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 111 | System.out.println ("RightLegOff: se la gamba destra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 112 | System.out.println ("Exit: esci dal programma"); | ||
| 113 | System.out.println (""); | ||
| 114 | System.out.println ("Comandi a sorpresa:"); | ||
| 115 | System.out.println (""); | ||
| 116 | System.out.println ("Exploud"); | ||
| 117 | System.out.println ("Bier"); | ||
| 118 | System.out.println ("Rename"); | ||
| 119 | System.out.println ("Porky"); | ||
| 120 | System.out.println ("xxx"); | ||
| 121 | return ""; | ||
| 122 | |||
| 123 | } | ||
| 124 | else | ||
| 125 | System.out.println ("Comando non riconosciuto - digitare l per una legenda dei comandi disponibili"); | ||
| 126 | for (int i = 0, j = 0; i < pdr.length; i++) { | ||
| 127 | if (pdr[i].statoParte) { | ||
| 128 | contatore += 1; | ||
| 129 | stat[j++] = pdr[i].stringaParte; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | switch (contatore) { | ||
| 133 | case 0: | ||
| 134 | Return = "Comunque il robottino " + nomeRobot[0] + "non sta facendo niente"; | ||
| 135 | break; | ||
| 136 | case 1: | ||
| 137 | Return = "Immagini che il robottino " + nomeRobot[0] + "abbia " + stat[0] + "."; | ||
| 138 | break; | ||
| 139 | case 2: | ||
| 140 | Return = "Immagini che il robottino " + nomeRobot[0] + "abbia " + stat[0] + " e " + stat[1] + "."; | ||
| 141 | break; | ||
| 142 | case 3: | ||
| 143 | Return = "Immagini che il robottino " + nomeRobot[0] + "abbia " + stat[0] + ", " + stat[1] + " e " + stat[2] + "."; | ||
| 144 | break; | ||
| 145 | case 4: | ||
| 146 | Return = "Immagini che il robottino " + nomeRobot[0] + "abbia " + stat[0] + ", " + stat[1] + ", " + stat[2] + " e " + stat[3] + "."; | ||
| 147 | break; | ||
| 148 | } | ||
| 149 | return Return; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | |||
| 159 | |||
| 160 | |||
diff --git a/robottino/all_versions/v2.0/Esegui.bat b/robottino/all_versions/v2.0/Esegui.bat new file mode 100755 index 0000000..1eb0b2e --- /dev/null +++ b/robottino/all_versions/v2.0/Esegui.bat | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | cd ./bin | ||
| 2 | java Robottino | ||
diff --git a/robottino/all_versions/v2.0/Esegui.sh b/robottino/all_versions/v2.0/Esegui.sh new file mode 100755 index 0000000..1eb0b2e --- /dev/null +++ b/robottino/all_versions/v2.0/Esegui.sh | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | cd ./bin | ||
| 2 | java Robottino | ||
diff --git a/robottino/all_versions/v2.0/Readme.txt b/robottino/all_versions/v2.0/Readme.txt new file mode 100755 index 0000000..52d532c --- /dev/null +++ b/robottino/all_versions/v2.0/Readme.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Il programma necessita della JVM (Java Virtual Machine) per funzionare correttamente | ||
| 2 | |||
| 3 | Se si usano sistemi Windows aprire il file Esegui.bat | ||
| 4 | Se si usano sistemi Unix dare i permessi necessari ed eseguire il file Esegui.sh | ||
| 5 | Se si usano altri sistemi aprire una shell e digitare i comandi | ||
| 6 | |||
| 7 | cd <percorsoFile>/bin | ||
| 8 | java Robottino | ||
| 9 | |||
| 10 | dove percorsoFile è il percorso di questo file. | ||
diff --git a/robottino/all_versions/v2.0/bin/PartiDelRobot.class b/robottino/all_versions/v2.0/bin/PartiDelRobot.class new file mode 100755 index 0000000..e6ffdb4 --- /dev/null +++ b/robottino/all_versions/v2.0/bin/PartiDelRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.0/bin/Robottino.class b/robottino/all_versions/v2.0/bin/Robottino.class new file mode 100755 index 0000000..e2228a1 --- /dev/null +++ b/robottino/all_versions/v2.0/bin/Robottino.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.0/src/PartiDelRobot.java b/robottino/all_versions/v2.0/src/PartiDelRobot.java new file mode 100755 index 0000000..3399dbc --- /dev/null +++ b/robottino/all_versions/v2.0/src/PartiDelRobot.java | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | public class PartiDelRobot { | ||
| 2 | PartiDelRobot() { }; | ||
| 3 | PartiDelRobot(boolean b, String s) { | ||
| 4 | this.stringaParte = s; | ||
| 5 | this.statoParte = b; | ||
| 6 | } | ||
| 7 | public String stringaParte; | ||
| 8 | public boolean statoParte; | ||
| 9 | } | ||
diff --git a/robottino/all_versions/v2.0/src/Robottino.java b/robottino/all_versions/v2.0/src/Robottino.java new file mode 100755 index 0000000..f1b0c49 --- /dev/null +++ b/robottino/all_versions/v2.0/src/Robottino.java | |||
| @@ -0,0 +1,270 @@ | |||
| 1 | import java.util.Scanner; | ||
| 2 | class Robottino extends PartiDelRobot { | ||
| 3 | static PartiDelRobot pdr[][] = { | ||
| 4 | { | ||
| 5 | new PartiDelRobot (false, "il braccio sinistro alzato"), | ||
| 6 | new PartiDelRobot (false, "il braccio destro alzato"), | ||
| 7 | new PartiDelRobot (false, "la gamba sinistra alzata"), | ||
| 8 | new PartiDelRobot (false, "la gamba destra alzata") | ||
| 9 | } | ||
| 10 | }; | ||
| 11 | static String nomeRobot[] = { "" }; | ||
| 12 | int robotIndex = 0; | ||
| 13 | public static void main(String argv[]) { | ||
| 14 | Scanner sc = new Scanner(System.in); | ||
| 15 | String comando; | ||
| 16 | Robottino robottino = new Robottino(); | ||
| 17 | System.out.println ("**********************************************"); | ||
| 18 | System.out.println ("**********************************************"); | ||
| 19 | System.out.println ("*************Programma interattivo************"); | ||
| 20 | System.out.println ("**********************************************"); | ||
| 21 | System.out.println ("***Software realizzato da Sebastiano Tronto***"); | ||
| 22 | System.out.println ("**********************************************"); | ||
| 23 | System.out.println ("**********************************************"); | ||
| 24 | System.out.println ("Questo programma simula un robot al quale ven-"); | ||
| 25 | System.out.println ("gono assegnati ordini tramite comandi, simil-" ); | ||
| 26 | System.out.println ("mente a quanto bisognava fare con i computer " ); | ||
| 27 | System.out.println ("alcuni anni fa." ); | ||
| 28 | System.out.println ("Dato che all'epoca i comandi che dovevano es-" ); | ||
| 29 | System.out.println ("sere dati erano (e sono tutt'ora) in similin-" ); | ||
| 30 | System.out.println ("glese, ho cercato di mantenerli tali." ); | ||
| 31 | System.out.println ("Il programma non fa distinzioni tra lettere" ); | ||
| 32 | System.out.println ("maiuscole o minuscole." ); | ||
| 33 | System.out.println ("In questa versione non sono ancora disponibi-" ); | ||
| 34 | System.out.println ("li immagini e/o effetti grafici." ); | ||
| 35 | System.out.println ("" ); | ||
| 36 | System.out.println ("Digita un comando e premi INVIO" ); | ||
| 37 | System.out.println ("l = legenda comandi" ); | ||
| 38 | System.out.println (""); | ||
| 39 | do { | ||
| 40 | comando = sc.nextLine(); | ||
| 41 | System.out.println (""); | ||
| 42 | System.out.println (robottino.Azioni(comando, nomeRobot, pdr)); | ||
| 43 | System.out.println (""); | ||
| 44 | } while ( !(comando.equalsIgnoreCase("exit")) ); | ||
| 45 | } | ||
| 46 | String Azioni(String comando, String nomeRobot[], PartiDelRobot pdr[][]) { | ||
| 47 | Scanner sc2 = new Scanner(System.in); | ||
| 48 | int contatore = 0; | ||
| 49 | String stat[] = {"", "", "", ""}; | ||
| 50 | String Return = "Errore - si consiglia di picchiare il programmatore"; | ||
| 51 | if (comando.equalsIgnoreCase("leftarmmove")) | ||
| 52 | this.pdr[this.robotIndex][0].statoParte = !this.pdr[this.robotIndex][0].statoParte; | ||
| 53 | else if (comando.equalsIgnoreCase("rightarmmove")) | ||
| 54 | this.pdr[this.robotIndex][1].statoParte = !this.pdr[this.robotIndex][1].statoParte; | ||
| 55 | else if (comando.equalsIgnoreCase("leftlegmove")) | ||
| 56 | this.pdr[this.robotIndex][2].statoParte = !this.pdr[this.robotIndex][2].statoParte; | ||
| 57 | else if (comando.equalsIgnoreCase("rightlegmove")) | ||
| 58 | this.pdr[this.robotIndex][3].statoParte = !this.pdr[this.robotIndex][3].statoParte; | ||
| 59 | else if (comando.equalsIgnoreCase("leftarmon")) | ||
| 60 | this.pdr[this.robotIndex][0].statoParte = true; | ||
| 61 | else if (comando.equalsIgnoreCase("rightarmon")) | ||
| 62 | this.pdr[this.robotIndex][1].statoParte = true; | ||
| 63 | else if (comando.equalsIgnoreCase("leftlegon")) | ||
| 64 | this.pdr[this.robotIndex][2].statoParte = true; | ||
| 65 | else if (comando.equalsIgnoreCase("rightlegon")) | ||
| 66 | this.pdr[this.robotIndex][3].statoParte = true; | ||
| 67 | else if (comando.equalsIgnoreCase("leftarmoff")) | ||
| 68 | this.pdr[this.robotIndex][0].statoParte = false; | ||
| 69 | else if (comando.equalsIgnoreCase("rightarmoff")) | ||
| 70 | this.pdr[this.robotIndex][1].statoParte = false; | ||
| 71 | else if (comando.equalsIgnoreCase("leftlegoff")) | ||
| 72 | this.pdr[this.robotIndex][2].statoParte = false; | ||
| 73 | else if (comando.equalsIgnoreCase("rightlegoff")) | ||
| 74 | this.pdr[this.robotIndex][3].statoParte = false; | ||
| 75 | else if (comando.equalsIgnoreCase("exploud")) { | ||
| 76 | System.out.println ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot[this.robotIndex] + "! Aspetta che te ne faccio un altro"); | ||
| 77 | System.out.println ("..."); | ||
| 78 | for (int i = 0; i < pdr[this.robotIndex].length; i++) { | ||
| 79 | pdr[this.robotIndex][i].statoParte = false; | ||
| 80 | } | ||
| 81 | nomeRobot[this.robotIndex] = ""; | ||
| 82 | return "Fatto, puoi continuare a giocare"; | ||
| 83 | } | ||
| 84 | else if (comando.equalsIgnoreCase("bier")) { | ||
| 85 | System.out.println ("Il robottino " + nomeRobot[this.robotIndex] + "sta trangugiando una birra..."); | ||
| 86 | System.out.println ("Buurrrrrrrrp!"); | ||
| 87 | return "La birra analcolica fa schifo!"; | ||
| 88 | } | ||
| 89 | else if (comando.equalsIgnoreCase("rename")) { | ||
| 90 | System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot[this.robotIndex]); | ||
| 91 | System.out.println ("Digita il nuovo nome e premi invio per coninuare"); | ||
| 92 | nomeRobot[this.robotIndex] = sc2.nextLine(); | ||
| 93 | if (!(nomeRobot[this.robotIndex].equalsIgnoreCase(""))) | ||
| 94 | nomeRobot[this.robotIndex] += " "; | ||
| 95 | return "Ora il robottino si chiama " + nomeRobot[this.robotIndex]; | ||
| 96 | } | ||
| 97 | else if (comando.equalsIgnoreCase("porky")) { | ||
| 98 | System.out.println ("Porky è un grande"); | ||
| 99 | System.out.println ("Per maggiori informazioni visita il sito"); | ||
| 100 | return "http://kakati.forumfree.net/"; | ||
| 101 | } | ||
| 102 | else if (comando.equalsIgnoreCase("xxx")) { | ||
| 103 | System.out.println ("Il robottino " + nomeRobot[this.robotIndex] + "ha incontrato una bella robottina..."); | ||
| 104 | return "*Censura*"; | ||
| 105 | } | ||
| 106 | else if (comando.equalsIgnoreCase("dance")) { | ||
| 107 | System.out.println ("Immagini che il robottino " + nomeRobot[this.robotIndex] + " stia ballando..."); | ||
| 108 | System.out.println ("Il robottino ha smesso di ballare"); | ||
| 109 | for (int i = 0; i < pdr[this.robotIndex].length; i++) { | ||
| 110 | pdr[0][i].statoParte = false; | ||
| 111 | } | ||
| 112 | return "Il robottino " + nomeRobot[this.robotIndex] + "si è fermato ed è tornato nella posizione originale"; | ||
| 113 | } | ||
| 114 | else if (comando.equalsIgnoreCase("newrobot")) { | ||
| 115 | PartiDelRobot pdrAus[][] = new PartiDelRobot[(addRobot(this.pdr, this.pdr[this.robotIndex])).length][(addRobot(this.pdr, this.pdr[this.robotIndex]))[(addRobot(this.pdr, this.pdr[this.robotIndex])).length-1].length]; | ||
| 116 | this.pdr = new PartiDelRobot[pdrAus.length][pdrAus[pdrAus.length-1].length]; | ||
| 117 | for (int i=0; i<pdrAus.length; i++) { | ||
| 118 | for (int j=0; j<pdrAus[i].length; j++) { | ||
| 119 | pdrAus[i][j] = (addRobot(pdr, pdr[this.robotIndex]))[i][j]; | ||
| 120 | pdrAus[i][j].stringaParte = (addRobot(pdr, pdr[this.robotIndex]))[i][j].stringaParte; | ||
| 121 | pdrAus[i][j].statoParte = (addRobot(pdr, pdr[this.robotIndex]))[i][j].statoParte; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | for (int i=0; i<this.pdr.length; i++) { | ||
| 125 | for (int j=0; j<this.pdr[i].length; j++) { | ||
| 126 | this.pdr[i][j] = pdrAus[i][j]; | ||
| 127 | this.pdr[i][j].stringaParte = pdrAus[i][j].stringaParte; | ||
| 128 | this.pdr[i][j].statoParte = pdrAus[i][j].statoParte; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | System.out.println ("È stato creato un nuovo robot. Vuoi dare un nome al nuovo robot?"); | ||
| 132 | System.out.println ("Inserisci il nuovo nome e premi INVIO oppure lascia vuoto e premi INVIO"); | ||
| 133 | String newName = sc2.nextLine(); | ||
| 134 | String nomeRobotAus[] = new String[(addName(this.nomeRobot, newName)).length]; | ||
| 135 | this.nomeRobot = new String[nomeRobotAus.length]; | ||
| 136 | for (int i=0; i<nomeRobotAus.length; i++) { | ||
| 137 | nomeRobotAus[i] = (addName(nomeRobot, newName))[i]; | ||
| 138 | } | ||
| 139 | for (int i=0; i<nomeRobotAus.length; i++) { | ||
| 140 | this.nomeRobot[i] = nomeRobotAus[i]; | ||
| 141 | } | ||
| 142 | return "È stato creato il robottino " + newName; | ||
| 143 | } | ||
| 144 | else if (comando.equalsIgnoreCase("deleterobot")) | ||
| 145 | return "Comando non disponibile in questa versione del programma"; | ||
| 146 | else if (comando.equalsIgnoreCase("changerobot")) { | ||
| 147 | if (pdr.length==1) { | ||
| 148 | return "Hai solo un robottino, non puoi cambiarlo con un altro!"; | ||
| 149 | } | ||
| 150 | else { | ||
| 151 | System.out.println ("A quale robottino vuoi dare i comandi?"); | ||
| 152 | System.out.println (""); | ||
| 153 | for (int numRobot = 0; numRobot<this.pdr.length; numRobot++) { | ||
| 154 | System.out.println (numRobot + ". " + this.nomeRobot[numRobot]); | ||
| 155 | } | ||
| 156 | System.out.println (""); | ||
| 157 | System.out.println ("Digita il numero corrispondente alla tua scelta e premi INVIO"); | ||
| 158 | this.robotIndex = sc2.nextInt(); | ||
| 159 | if (this.robotIndex<this.pdr.length) | ||
| 160 | return "È stato selezionato il robottino numero " + this.robotIndex + ": " + this.nomeRobot[this.robotIndex]; | ||
| 161 | else | ||
| 162 | return "Numero non valido"; | ||
| 163 | } | ||
| 164 | } | ||
| 165 | else if (comando.equalsIgnoreCase("robotlist")) { | ||
| 166 | for (int numRobot = 0; numRobot<this.pdr.length; numRobot++) { | ||
| 167 | System.out.println (numRobot + ". " + this.nomeRobot[numRobot]); | ||
| 168 | } | ||
| 169 | return ""; | ||
| 170 | } | ||
| 171 | else if (comando.equalsIgnoreCase("l")) { | ||
| 172 | System.out.println ("Legenda comandi"); | ||
| 173 | System.out.println (""); | ||
| 174 | System.out.println ("Comandi relativi agli arti"); | ||
| 175 | System.out.println (""); | ||
| 176 | System.out.println ("LeftArmMove: cambia la posizione corrente del braccio sinistro del robot"); | ||
| 177 | System.out.println ("RightArmMove: cambia la posizione corrente del braccio destro del robot"); | ||
| 178 | System.out.println ("LeftLegMove: cambia la posizione corrente della gamba sinistra del robot"); | ||
| 179 | System.out.println ("RightLegMove: cambia la posizione corrente della gamba destra del robot"); | ||
| 180 | System.out.println ("LeftArmOn: se il braccio sinistro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 181 | System.out.println ("RightArmOn: se il braccio destro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 182 | System.out.println ("LeftLegOn: se la gamba sinistra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 183 | System.out.println ("RightLegOn: se la gamba destra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 184 | System.out.println ("LeftArmOff: se il braccio sinistro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 185 | System.out.println ("RightArmOff: se il braccio destro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 186 | System.out.println ("LeftLegOff: se la gamba sinistra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 187 | System.out.println ("RightLegOff: se la gamba destra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 188 | System.out.println (""); | ||
| 189 | System.out.println ("Altri comandi:"); | ||
| 190 | System.out.println (""); | ||
| 191 | System.out.println ("NewRobot: aggiunge un nuovo robot"); | ||
| 192 | System.out.println ("ChangeRobot: cambia il robot attuale"); | ||
| 193 | System.out.println ("RobotList: visualizza la lista dei robot"); | ||
| 194 | System.out.println ("Rename: rinomina il robottino"); | ||
| 195 | System.out.println (""); | ||
| 196 | System.out.println ("Comandi a sorpresa:"); | ||
| 197 | System.out.println (""); | ||
| 198 | System.out.println ("Exploud"); | ||
| 199 | System.out.println ("Bier"); | ||
| 200 | System.out.println ("Porky"); | ||
| 201 | System.out.println ("xxx"); | ||
| 202 | System.out.println ("dance"); | ||
| 203 | System.out.println (""); | ||
| 204 | System.out.println ("Exit: esci dal programma"); | ||
| 205 | return ""; | ||
| 206 | |||
| 207 | } | ||
| 208 | else if (comando.equalsIgnoreCase("exit")) | ||
| 209 | return ""; | ||
| 210 | else | ||
| 211 | System.out.println ("Comando non riconosciuto - digitare l per una legenda dei comandi disponibili"); | ||
| 212 | System.out.println (""); | ||
| 213 | for (int i = 0, j = 0; i < pdr[this.robotIndex].length; i++) { | ||
| 214 | if (pdr[robotIndex][i].statoParte) { | ||
| 215 | contatore += 1; | ||
| 216 | stat[j++] = pdr[this.robotIndex][i].stringaParte; | ||
| 217 | } | ||
| 218 | } | ||
| 219 | switch (contatore) { | ||
| 220 | case 0: | ||
| 221 | Return = "Comunque il robottino " + nomeRobot[this.robotIndex] + "non sta facendo niente"; | ||
| 222 | break; | ||
| 223 | case 1: | ||
| 224 | Return = "Immagini che il robottino " + nomeRobot[this.robotIndex] + "abbia " + stat[0] + "."; | ||
| 225 | break; | ||
| 226 | case 2: | ||
| 227 | Return = "Immagini che il robottino " + nomeRobot[this.robotIndex] + "abbia " + stat[0] + " e " + stat[1] + "."; | ||
| 228 | break; | ||
| 229 | case 3: | ||
| 230 | Return = "Immagini che il robottino " + nomeRobot[this.robotIndex] + "abbia " + stat[0] + ", " + stat[1] + " e " + stat[2] + "."; | ||
| 231 | break; | ||
| 232 | case 4: | ||
| 233 | Return = "Immagini che il robottino " + nomeRobot[this.robotIndex] + "abbia " + stat[0] + ", " + stat[1] + ", " + stat[2] + " e " + stat[3] + "."; | ||
| 234 | break; | ||
| 235 | } | ||
| 236 | return Return; | ||
| 237 | } | ||
| 238 | static PartiDelRobot[][] addRobot(PartiDelRobot pdrOld[][], PartiDelRobot pdrElement[]) { | ||
| 239 | PartiDelRobot pdrNew[][] = new PartiDelRobot [pdrOld.length+1][pdrOld[pdrOld.length-1].length]; | ||
| 240 | for (int i=0; i<pdrOld.length; i++) { | ||
| 241 | for (int j=0; j<pdrOld[i].length; j++) { | ||
| 242 | pdrNew[i][j] = new PartiDelRobot(pdrOld[i][j].statoParte, pdrOld[i][j].stringaParte); | ||
| 243 | } | ||
| 244 | } | ||
| 245 | for (int i=0; i<pdrElement.length; i++) { | ||
| 246 | pdrNew[pdrNew.length-1][i] = new PartiDelRobot(false, pdrElement[i].stringaParte); | ||
| 247 | } | ||
| 248 | return pdrNew; | ||
| 249 | } | ||
| 250 | static String[] addName(String nomeRobot[], String name) { | ||
| 251 | String nomeNewRobot[] = new String [nomeRobot.length+1]; | ||
| 252 | for (int i=0; i<nomeRobot.length; i++) { | ||
| 253 | nomeNewRobot[i] = nomeRobot[i]; | ||
| 254 | } | ||
| 255 | nomeNewRobot[nomeNewRobot.length-1] = name; | ||
| 256 | if (!(nomeNewRobot[nomeNewRobot.length-1].equalsIgnoreCase(""))) { | ||
| 257 | nomeNewRobot[nomeNewRobot.length-1] += " "; | ||
| 258 | } | ||
| 259 | return nomeNewRobot; | ||
| 260 | } | ||
| 261 | } | ||
| 262 | |||
| 263 | |||
| 264 | |||
| 265 | |||
| 266 | |||
| 267 | |||
| 268 | |||
| 269 | |||
| 270 | |||
diff --git a/robottino/all_versions/v2.1/Esegui.bat b/robottino/all_versions/v2.1/Esegui.bat new file mode 100755 index 0000000..1eb0b2e --- /dev/null +++ b/robottino/all_versions/v2.1/Esegui.bat | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | cd ./bin | ||
| 2 | java Robottino | ||
diff --git a/robottino/all_versions/v2.1/Esegui.sh b/robottino/all_versions/v2.1/Esegui.sh new file mode 100755 index 0000000..1eb0b2e --- /dev/null +++ b/robottino/all_versions/v2.1/Esegui.sh | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | cd ./bin | ||
| 2 | java Robottino | ||
diff --git a/robottino/all_versions/v2.1/Readme.txt b/robottino/all_versions/v2.1/Readme.txt new file mode 100755 index 0000000..52d532c --- /dev/null +++ b/robottino/all_versions/v2.1/Readme.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Il programma necessita della JVM (Java Virtual Machine) per funzionare correttamente | ||
| 2 | |||
| 3 | Se si usano sistemi Windows aprire il file Esegui.bat | ||
| 4 | Se si usano sistemi Unix dare i permessi necessari ed eseguire il file Esegui.sh | ||
| 5 | Se si usano altri sistemi aprire una shell e digitare i comandi | ||
| 6 | |||
| 7 | cd <percorsoFile>/bin | ||
| 8 | java Robottino | ||
| 9 | |||
| 10 | dove percorsoFile è il percorso di questo file. | ||
diff --git a/robottino/all_versions/v2.1/bin/PartiDelRobot.class b/robottino/all_versions/v2.1/bin/PartiDelRobot.class new file mode 100755 index 0000000..e6ffdb4 --- /dev/null +++ b/robottino/all_versions/v2.1/bin/PartiDelRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.1/bin/Robottino.class b/robottino/all_versions/v2.1/bin/Robottino.class new file mode 100755 index 0000000..b189de4 --- /dev/null +++ b/robottino/all_versions/v2.1/bin/Robottino.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.1/src/PartiDelRobot.java b/robottino/all_versions/v2.1/src/PartiDelRobot.java new file mode 100755 index 0000000..3399dbc --- /dev/null +++ b/robottino/all_versions/v2.1/src/PartiDelRobot.java | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | public class PartiDelRobot { | ||
| 2 | PartiDelRobot() { }; | ||
| 3 | PartiDelRobot(boolean b, String s) { | ||
| 4 | this.stringaParte = s; | ||
| 5 | this.statoParte = b; | ||
| 6 | } | ||
| 7 | public String stringaParte; | ||
| 8 | public boolean statoParte; | ||
| 9 | } | ||
diff --git a/robottino/all_versions/v2.1/src/Robottino.java b/robottino/all_versions/v2.1/src/Robottino.java new file mode 100755 index 0000000..550e027 --- /dev/null +++ b/robottino/all_versions/v2.1/src/Robottino.java | |||
| @@ -0,0 +1,258 @@ | |||
| 1 | import java.util.Scanner; | ||
| 2 | import java.util.Vector; | ||
| 3 | class Robottino extends PartiDelRobot { | ||
| 4 | static Robottino robottino = new Robottino(); | ||
| 5 | static Vector pdrA = new Vector(1); | ||
| 6 | static Vector pdrB = new Vector(4); | ||
| 7 | static PartiDelRobot leftArm = new PartiDelRobot(false, "il braccio sinistro alzato"); | ||
| 8 | static PartiDelRobot rightArm = new PartiDelRobot(false, "il braccio destro alzato"); | ||
| 9 | static PartiDelRobot leftLeg = new PartiDelRobot(false, "la gamba sinistra alzata"); | ||
| 10 | static PartiDelRobot rightLeg = new PartiDelRobot(false, "la gamba destra alzata"); | ||
| 11 | static Vector nomeRobot = new Vector(1); | ||
| 12 | static int robotIndex = 0; | ||
| 13 | public static void main(String argv[]) { | ||
| 14 | pdrB.addElement(leftArm); | ||
| 15 | pdrB.addElement(rightArm); | ||
| 16 | pdrB.addElement(leftLeg); | ||
| 17 | pdrB.addElement(rightLeg); | ||
| 18 | pdrA.addElement(pdrB); | ||
| 19 | nomeRobot.addElement(""); | ||
| 20 | Scanner sc = new Scanner(System.in); | ||
| 21 | String comando; | ||
| 22 | System.out.println ("**********************************************"); | ||
| 23 | System.out.println ("**********************************************"); | ||
| 24 | System.out.println ("*************Programma interattivo************"); | ||
| 25 | System.out.println ("**********************************************"); | ||
| 26 | System.out.println ("***Software realizzato da Sebastiano Tronto***"); | ||
| 27 | System.out.println ("**********************************************"); | ||
| 28 | System.out.println ("**********************************************"); | ||
| 29 | System.out.println ("Questo programma simula un robot al quale ven-"); | ||
| 30 | System.out.println ("gono assegnati ordini tramite comandi, simil-" ); | ||
| 31 | System.out.println ("mente a quanto bisognava fare con i computer " ); | ||
| 32 | System.out.println ("alcuni anni fa." ); | ||
| 33 | System.out.println ("Dato che all'epoca i comandi che dovevano es-" ); | ||
| 34 | System.out.println ("sere dati erano (e sono tutt'ora) in similin-" ); | ||
| 35 | System.out.println ("glese, ho cercato di mantenerli tali." ); | ||
| 36 | System.out.println ("Il programma non fa distinzioni tra lettere" ); | ||
| 37 | System.out.println ("maiuscole o minuscole." ); | ||
| 38 | System.out.println ("In questa versione non sono ancora disponibi-" ); | ||
| 39 | System.out.println ("li immagini e/o effetti grafici." ); | ||
| 40 | System.out.println ("" ); | ||
| 41 | System.out.println ("Digita un comando e premi INVIO" ); | ||
| 42 | System.out.println ("l = legenda comandi" ); | ||
| 43 | System.out.println (""); | ||
| 44 | do { | ||
| 45 | comando = sc.nextLine(); | ||
| 46 | System.out.println (""); | ||
| 47 | System.out.println (robottino.Azioni(comando, nomeRobot, pdrA)); | ||
| 48 | System.out.println (""); | ||
| 49 | } while ( !(comando.equalsIgnoreCase("exit")) ); | ||
| 50 | } | ||
| 51 | String Azioni(String comando, Vector nomeRobot, Vector pdrA) { | ||
| 52 | Scanner sc2 = new Scanner(System.in); | ||
| 53 | int contatore = 0; | ||
| 54 | String stat[] = {"", "", "", ""}; | ||
| 55 | String Return = "Errore - si consiglia di picchiare il programmatore"; | ||
| 56 | if (comando.equalsIgnoreCase("leftarmmove")) | ||
| 57 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte; | ||
| 58 | else if (comando.equalsIgnoreCase("rightarmmove")) | ||
| 59 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte; | ||
| 60 | else if (comando.equalsIgnoreCase("leftlegmove")) | ||
| 61 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte; | ||
| 62 | else if (comando.equalsIgnoreCase("rightlegmove")) | ||
| 63 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte; | ||
| 64 | else if (comando.equalsIgnoreCase("leftarmon")) | ||
| 65 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = true; | ||
| 66 | else if (comando.equalsIgnoreCase("rightarmon")) | ||
| 67 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = true; | ||
| 68 | else if (comando.equalsIgnoreCase("leftlegon")) | ||
| 69 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = true; | ||
| 70 | else if (comando.equalsIgnoreCase("rightlegon")) | ||
| 71 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = true; | ||
| 72 | else if (comando.equalsIgnoreCase("leftarmoff")) | ||
| 73 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = false; | ||
| 74 | else if (comando.equalsIgnoreCase("rightarmoff")) | ||
| 75 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = false; | ||
| 76 | else if (comando.equalsIgnoreCase("leftlegoff")) | ||
| 77 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = false; | ||
| 78 | else if (comando.equalsIgnoreCase("rightlegoff")) | ||
| 79 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = false; | ||
| 80 | else if (comando.equalsIgnoreCase("exploud")) { | ||
| 81 | System.out.println ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot.elementAt(this.robotIndex) + "! Aspetta che te ne faccio un altro"); | ||
| 82 | System.out.println ("..."); | ||
| 83 | for (int i = 0; i < 4; i++) { | ||
| 84 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 85 | } | ||
| 86 | this.nomeRobot.setElementAt("", this.robotIndex); | ||
| 87 | return "Fatto, puoi continuare a giocare"; | ||
| 88 | } | ||
| 89 | else if (comando.equalsIgnoreCase("bier")) { | ||
| 90 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "sta trangugiando una birra..."); | ||
| 91 | System.out.println ("Buurrrrrrrrp!"); | ||
| 92 | return "La birra analcolica fa schifo!"; | ||
| 93 | } | ||
| 94 | else if (comando.equalsIgnoreCase("rename")) { | ||
| 95 | System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot.elementAt(this.robotIndex)); | ||
| 96 | System.out.println ("Digita il nuovo nome e premi invio per coninuare"); | ||
| 97 | this.nomeRobot.setElementAt(sc2.nextLine(), this.robotIndex); | ||
| 98 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 99 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 100 | return "Ora il robottino si chiama " + nomeRobot.elementAt(this.robotIndex); | ||
| 101 | } | ||
| 102 | else if (comando.equalsIgnoreCase("porky")) { | ||
| 103 | System.out.println ("Porky è un grande"); | ||
| 104 | System.out.println ("Per maggiori informazioni visita il sito"); | ||
| 105 | return "http://kakati.forumfree.net/"; | ||
| 106 | } | ||
| 107 | else if (comando.equalsIgnoreCase("xxx")) { | ||
| 108 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "ha incontrato una bella robottina..."); | ||
| 109 | return "*Censura*"; | ||
| 110 | } | ||
| 111 | else if (comando.equalsIgnoreCase("dance")) { | ||
| 112 | System.out.println ("Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + " stia ballando..."); | ||
| 113 | System.out.println ("Il robottino ha smesso di ballare"); | ||
| 114 | for (int i = 0; i < 4; i++) { | ||
| 115 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 116 | } | ||
| 117 | return "Il robottino " + nomeRobot.elementAt(this.robotIndex) + "si è fermato ed è tornato nella posizione originale"; | ||
| 118 | } | ||
| 119 | else if (comando.equalsIgnoreCase("newrobot")) { | ||
| 120 | this.pdrA.addElement(pdrB); | ||
| 121 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftArm); | ||
| 122 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightArm); | ||
| 123 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftLeg); | ||
| 124 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightLeg); | ||
| 125 | System.out.println ("È stato creato un nuovo robot. Vuoi dare un nome al nuovo robot?"); | ||
| 126 | System.out.println ("Inserisci il nuovo nome e premi INVIO oppure lascia vuoto e premi INVIO"); | ||
| 127 | String newName = sc2.nextLine(); | ||
| 128 | this.nomeRobot.addElement(newName); | ||
| 129 | return "È stato creato il robottino " + newName; | ||
| 130 | } | ||
| 131 | else if (comando.equalsIgnoreCase("deleterobot")) { | ||
| 132 | if (pdrA.size()>1) { | ||
| 133 | System.out.println ("Quale robottino vuoi eliminare?"); | ||
| 134 | System.out.println (""); | ||
| 135 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 136 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 137 | } | ||
| 138 | System.out.println (""); | ||
| 139 | System.out.println("Scegliere il robottino da eliminare digitando il numero corrispondente e premendo INVIO"); | ||
| 140 | System.out.println("Digitare un qualunque altro numero e premere INVIO per annullare"); | ||
| 141 | int num = sc2.nextInt(); | ||
| 142 | if (num<this.pdrA.size()) { | ||
| 143 | this.pdrA.removeElementAt(num); | ||
| 144 | this.nomeRobot.removeElementAt(num); | ||
| 145 | return "È stato eliminato il robottino numero " + num; | ||
| 146 | } | ||
| 147 | else { | ||
| 148 | return "Operazione annullata"; | ||
| 149 | } | ||
| 150 | } | ||
| 151 | else { | ||
| 152 | return "Hai solo un robottino, non puoi eliminarlo!"; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | else if (comando.equalsIgnoreCase("changerobot")) { | ||
| 156 | if (pdrA.size()>1) { | ||
| 157 | System.out.println ("A quale robottino vuoi dare i comandi?"); | ||
| 158 | System.out.println (""); | ||
| 159 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 160 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 161 | } | ||
| 162 | System.out.println (""); | ||
| 163 | System.out.println ("Digita il numero corrispondente alla tua scelta e premi INVIO"); | ||
| 164 | this.robotIndex = sc2.nextInt(); | ||
| 165 | if (this.robotIndex<this.pdrA.size()) | ||
| 166 | return "È stato selezionato il robottino numero " + this.robotIndex + ": " + | ||
| 167 | this.nomeRobot.elementAt(this.robotIndex); | ||
| 168 | else | ||
| 169 | return "Numero non valido"; | ||
| 170 | } | ||
| 171 | else { | ||
| 172 | return "Hai solo un robottino, non puoi cambiarlo con un altro!"; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | else if (comando.equalsIgnoreCase("robotlist")) { | ||
| 176 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 177 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 178 | } | ||
| 179 | return ""; | ||
| 180 | } | ||
| 181 | else if (comando.equalsIgnoreCase("l")) { | ||
| 182 | System.out.println ("Legenda comandi"); | ||
| 183 | System.out.println (""); | ||
| 184 | System.out.println ("Comandi relativi agli arti"); | ||
| 185 | System.out.println (""); | ||
| 186 | System.out.println ("LeftArmMove: cambia la posizione corrente del braccio sinistro del robot"); | ||
| 187 | System.out.println ("RightArmMove: cambia la posizione corrente del braccio destro del robot"); | ||
| 188 | System.out.println ("LeftLegMove: cambia la posizione corrente della gamba sinistra del robot"); | ||
| 189 | System.out.println ("RightLegMove: cambia la posizione corrente della gamba destra del robot"); | ||
| 190 | System.out.println ("LeftArmOn: se il braccio sinistro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 191 | System.out.println ("RightArmOn: se il braccio destro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 192 | System.out.println ("LeftLegOn: se la gamba sinistra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 193 | System.out.println ("RightLegOn: se la gamba destra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 194 | System.out.println ("LeftArmOff: se il braccio sinistro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 195 | System.out.println ("RightArmOff: se il braccio destro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 196 | System.out.println ("LeftLegOff: se la gamba sinistra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 197 | System.out.println ("RightLegOff: se la gamba destra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 198 | System.out.println (""); | ||
| 199 | System.out.println ("Altri comandi:"); | ||
| 200 | System.out.println (""); | ||
| 201 | System.out.println ("NewRobot: aggiunge un nuovo robot"); | ||
| 202 | System.out.println ("ChangeRobot: cambia il robot attuale"); | ||
| 203 | System.out.println ("RobotList: visualizza la lista dei robot"); | ||
| 204 | System.out.println ("Rename: rinomina il robottino"); | ||
| 205 | System.out.println ("DeleteRobot: rimuovi un robottino"); | ||
| 206 | System.out.println (""); | ||
| 207 | System.out.println ("Comandi a sorpresa:"); | ||
| 208 | System.out.println (""); | ||
| 209 | System.out.println ("Exploud"); | ||
| 210 | System.out.println ("Bier"); | ||
| 211 | System.out.println ("Porky"); | ||
| 212 | System.out.println ("xxx"); | ||
| 213 | System.out.println ("dance"); | ||
| 214 | System.out.println (""); | ||
| 215 | System.out.println ("Exit: esci dal programma"); | ||
| 216 | return ""; | ||
| 217 | |||
| 218 | } | ||
| 219 | else if (comando.equalsIgnoreCase("exit")) | ||
| 220 | return ""; | ||
| 221 | else | ||
| 222 | System.out.println ("Comando non riconosciuto - digitare l per una legenda dei comandi disponibili"); | ||
| 223 | System.out.println (""); | ||
| 224 | for (int i = 0, j = 0; i < ((Vector)pdrA.elementAt(this.robotIndex)).size(); i++) { | ||
| 225 | if (((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte) { | ||
| 226 | contatore += 1; | ||
| 227 | stat[j++] = ((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).stringaParte; | ||
| 228 | } | ||
| 229 | } | ||
| 230 | switch (contatore) { | ||
| 231 | case 0: | ||
| 232 | Return = "Comunque il robottino " + nomeRobot.elementAt(this.robotIndex) + "non sta facendo niente"; | ||
| 233 | break; | ||
| 234 | case 1: | ||
| 235 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + "."; | ||
| 236 | break; | ||
| 237 | case 2: | ||
| 238 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + " e " + stat[1] + "."; | ||
| 239 | break; | ||
| 240 | case 3: | ||
| 241 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + ", " + stat[1] + " e " + stat[2] + "."; | ||
| 242 | break; | ||
| 243 | case 4: | ||
| 244 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + ", " + stat[1] + ", " + stat[2] + " e " + stat[3] + "."; | ||
| 245 | break; | ||
| 246 | } | ||
| 247 | return Return; | ||
| 248 | } | ||
| 249 | } | ||
| 250 | |||
| 251 | |||
| 252 | |||
| 253 | |||
| 254 | |||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | |||
diff --git a/robottino/all_versions/v2.2/Esegui.bat b/robottino/all_versions/v2.2/Esegui.bat new file mode 100755 index 0000000..d413ed8 --- /dev/null +++ b/robottino/all_versions/v2.2/Esegui.bat | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | cd ./bin | ||
| 2 | java RobottinoMain/Robottino | ||
| 3 | cd | ||
diff --git a/robottino/all_versions/v2.2/Esegui.sh b/robottino/all_versions/v2.2/Esegui.sh new file mode 100755 index 0000000..d413ed8 --- /dev/null +++ b/robottino/all_versions/v2.2/Esegui.sh | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | cd ./bin | ||
| 2 | java RobottinoMain/Robottino | ||
| 3 | cd | ||
diff --git a/robottino/all_versions/v2.2/Readme.txt b/robottino/all_versions/v2.2/Readme.txt new file mode 100755 index 0000000..52d532c --- /dev/null +++ b/robottino/all_versions/v2.2/Readme.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Il programma necessita della JVM (Java Virtual Machine) per funzionare correttamente | ||
| 2 | |||
| 3 | Se si usano sistemi Windows aprire il file Esegui.bat | ||
| 4 | Se si usano sistemi Unix dare i permessi necessari ed eseguire il file Esegui.sh | ||
| 5 | Se si usano altri sistemi aprire una shell e digitare i comandi | ||
| 6 | |||
| 7 | cd <percorsoFile>/bin | ||
| 8 | java Robottino | ||
| 9 | |||
| 10 | dove percorsoFile è il percorso di questo file. | ||
diff --git a/robottino/all_versions/v2.2/bin/RobottinoAzioni/RobottinoAzioni.class b/robottino/all_versions/v2.2/bin/RobottinoAzioni/RobottinoAzioni.class new file mode 100755 index 0000000..16a771f --- /dev/null +++ b/robottino/all_versions/v2.2/bin/RobottinoAzioni/RobottinoAzioni.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.2/bin/RobottinoMain/Robottino.class b/robottino/all_versions/v2.2/bin/RobottinoMain/Robottino.class new file mode 100755 index 0000000..d65be46 --- /dev/null +++ b/robottino/all_versions/v2.2/bin/RobottinoMain/Robottino.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.2/bin/RobottinoUtils/Grafica.class b/robottino/all_versions/v2.2/bin/RobottinoUtils/Grafica.class new file mode 100755 index 0000000..b5f50a9 --- /dev/null +++ b/robottino/all_versions/v2.2/bin/RobottinoUtils/Grafica.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.2/bin/RobottinoUtils/Listener.class b/robottino/all_versions/v2.2/bin/RobottinoUtils/Listener.class new file mode 100755 index 0000000..d5b67f0 --- /dev/null +++ b/robottino/all_versions/v2.2/bin/RobottinoUtils/Listener.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.2/bin/RobottinoUtils/PartiDelRobot.class b/robottino/all_versions/v2.2/bin/RobottinoUtils/PartiDelRobot.class new file mode 100755 index 0000000..fcc8e9e --- /dev/null +++ b/robottino/all_versions/v2.2/bin/RobottinoUtils/PartiDelRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.2/src/RobottinoAzioni/RobottinoAzioni.java b/robottino/all_versions/v2.2/src/RobottinoAzioni/RobottinoAzioni.java new file mode 100755 index 0000000..96ad922 --- /dev/null +++ b/robottino/all_versions/v2.2/src/RobottinoAzioni/RobottinoAzioni.java | |||
| @@ -0,0 +1,369 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoAzioni, che verrà poi importato dalle classi Robottino e Grafica. | ||
| 2 | package RobottinoAzioni; | ||
| 3 | |||
| 4 | // Anche qui impoerto i package necessari. | ||
| 5 | import java.util.Scanner; | ||
| 6 | import java.util.Vector; | ||
| 7 | import RobottinoUtils.*; | ||
| 8 | |||
| 9 | public class RobottinoAzioni { | ||
| 10 | |||
| 11 | // Creo gli oggetti statici che riempiranno il vettore pdrA: | ||
| 12 | // pdrA è un vettore multidimensionale che a sua volta contiene vettori | ||
| 13 | // (il primo si chiama pdrB, i successivi non avranno nome) che coontengono | ||
| 14 | // 4 istanze di PartiDelRobot, cioè i 4 arti del robot. | ||
| 15 | // Poi creo un vettore che conterrà i nomi dei robot. | ||
| 16 | // Creo il vettore principale... | ||
| 17 | public static Vector pdrA = new Vector(1); | ||
| 18 | |||
| 19 | // ...e il "sottovettore" come istanze della classe Vector | ||
| 20 | public static Vector pdrB = new Vector(4); | ||
| 21 | |||
| 22 | // Creo le quattro istanze di PartidelRobot utilizzando l'apposito costruttore | ||
| 23 | // passo a tutte una stringa e un valore boleano che determina lo stato | ||
| 24 | // (alzato/a se true, abbassato/a se false). | ||
| 25 | public static PartiDelRobot leftArm = new PartiDelRobot(false, "il braccio sinistro alzato"); | ||
| 26 | public static PartiDelRobot rightArm = new PartiDelRobot(false, "il braccio destro alzato"); | ||
| 27 | public static PartiDelRobot leftLeg = new PartiDelRobot(false, "la gamba sinistra alzata"); | ||
| 28 | public static PartiDelRobot rightLeg = new PartiDelRobot(false, "la gamba destra alzata"); | ||
| 29 | |||
| 30 | // Il vettore nomeRobot per i nomi | ||
| 31 | // il vettore può contenere stringhe, poichè non sono tipi primitivi ma oggetti della classe String | ||
| 32 | public static Vector nomeRobot = new Vector(1); | ||
| 33 | |||
| 34 | // La variabile robotIndex serve a tenere in memoria su quale robot si sta operando: | ||
| 35 | // in seguito verrà usata quando l'utente deciderà di creare più di un robot | ||
| 36 | // e poi di dare comandi a uno o all'altro/i. | ||
| 37 | int robotIndex = 0; | ||
| 38 | |||
| 39 | // Dichiarazione del metodo Azioni. | ||
| 40 | public String Azioni(String comando, Vector nomeRobot, Vector pdrA) { | ||
| 41 | |||
| 42 | // Crea un'istanza della classe Scanner per | ||
| 43 | // ricevere gli input nel caso in cui debba essere dato il nome | ||
| 44 | // al robottino o scelto un robottino da una lista. | ||
| 45 | Scanner sc2 = new Scanner(System.in); | ||
| 46 | |||
| 47 | // La variabile contatore memorizza il numero di variabili "PartiDelRobot.statoParte" | ||
| 48 | // che hanno valore true, ossia il numero di arti alzati di un robottino | ||
| 49 | // in modo da poter scegliere la frase giusta da dare come output | ||
| 50 | // al posto dell'immagine del robottino con tali arti alzati. | ||
| 51 | int contatore = 0; | ||
| 52 | |||
| 53 | // Questo array ha il compito di memorizzare le stringhe corrispondenti agli alzati | ||
| 54 | // per motivi simili a quelli della variabile "contatore". | ||
| 55 | String stat[] = {"", "", "", ""}; | ||
| 56 | |||
| 57 | // La stringa Return verrà successivamente modificata e restituita in alcuni casi. | ||
| 58 | String Return = "Errore - si consiglia di picchiare il programmatore"; | ||
| 59 | |||
| 60 | // Per far si che il programma non distingua tra lettere maiuscole o minuscole per quanto riguardo gli input | ||
| 61 | // è stato usato il metodo "equalsIgnoreCase" della classe String. | ||
| 62 | // I quattro casi successivi cambiano il valore della varibalie "statoParte" relativa all'arto | ||
| 63 | // Che deve mouversi (quindi cambiare la sua posizione). | ||
| 64 | if (comando.equalsIgnoreCase("leftarmmove")) | ||
| 65 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = | ||
| 66 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte; | ||
| 67 | |||
| 68 | else if (comando.equalsIgnoreCase("rightarmmove")) | ||
| 69 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = | ||
| 70 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte; | ||
| 71 | |||
| 72 | else if (comando.equalsIgnoreCase("leftlegmove")) | ||
| 73 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = | ||
| 74 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte; | ||
| 75 | |||
| 76 | else if (comando.equalsIgnoreCase("rightlegmove")) | ||
| 77 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = | ||
| 78 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte; | ||
| 79 | |||
| 80 | // I casi successivi modificano il valore della varibile analogamente ai 4 precedenti. | ||
| 81 | else if (comando.equalsIgnoreCase("leftarmon")) | ||
| 82 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = true; | ||
| 83 | |||
| 84 | else if (comando.equalsIgnoreCase("rightarmon")) | ||
| 85 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = true; | ||
| 86 | |||
| 87 | else if (comando.equalsIgnoreCase("leftlegon")) | ||
| 88 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = true; | ||
| 89 | |||
| 90 | else if (comando.equalsIgnoreCase("rightlegon")) | ||
| 91 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = true; | ||
| 92 | |||
| 93 | else if (comando.equalsIgnoreCase("leftarmoff")) | ||
| 94 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = false; | ||
| 95 | |||
| 96 | else if (comando.equalsIgnoreCase("rightarmoff")) | ||
| 97 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = false; | ||
| 98 | |||
| 99 | else if (comando.equalsIgnoreCase("leftlegoff")) | ||
| 100 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = false; | ||
| 101 | |||
| 102 | else if (comando.equalsIgnoreCase("rightlegoff")) | ||
| 103 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = false; | ||
| 104 | |||
| 105 | // Il caso successi si verica quando il comando è "exploud". | ||
| 106 | else if (comando.equalsIgnoreCase("exploud")) { | ||
| 107 | |||
| 108 | // Scrive sullo schermo la seguente frase, che comprende il nome del robottino che non è ancora stato fatto eliminare | ||
| 109 | System.out.println | ||
| 110 | ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot.elementAt(this.robotIndex) + "! Aspetta che te ne faccio un altro"); | ||
| 111 | System.out.println ("..."); | ||
| 112 | |||
| 113 | // Con un ciclo for rendo false tutte le variabili "statoParte" per far sì che il robottino sia come nuovo. | ||
| 114 | for (int i = 0; i < 4; i++) { | ||
| 115 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 116 | } | ||
| 117 | |||
| 118 | // E azzero anche il nome del robot | ||
| 119 | this.nomeRobot.setElementAt("", this.robotIndex); | ||
| 120 | |||
| 121 | return "Fatto, puoi continuare a giocare"; | ||
| 122 | } | ||
| 123 | |||
| 124 | // Caso per il comando "bier". | ||
| 125 | // La reazione a questo comando è un semplice output quasi totalmente scorrelato al robottino | ||
| 126 | // se non per il fatto che appare il nome del robottino attuale. | ||
| 127 | else if (comando.equalsIgnoreCase("bier")) { | ||
| 128 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "sta trangugiando una birra..."); | ||
| 129 | System.out.println ("Buurrrrrrrrp!"); | ||
| 130 | return "La birra analcolica fa schifo!"; | ||
| 131 | } | ||
| 132 | |||
| 133 | // Per il comando "rename", rinomina. | ||
| 134 | else if (comando.equalsIgnoreCase("rename")) { | ||
| 135 | |||
| 136 | System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot.elementAt(this.robotIndex)); | ||
| 137 | System.out.println ("Digita il nuovo nome e premi INVIO per coninuare"); | ||
| 138 | |||
| 139 | // Cambia il nome del robottino attuale con quello dell'input. | ||
| 140 | this.nomeRobot.setElementAt(sc2.nextLine(), this.robotIndex); | ||
| 141 | |||
| 142 | // Se il nome non è vuoto, aggiunge un carattere di spazio per migliorare la visualizzazione nelle frasi di output. | ||
| 143 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 144 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 145 | |||
| 146 | // Semplice output con il nuovo nome. | ||
| 147 | return "Ora il robottino si chiama " + nomeRobot.elementAt(this.robotIndex); | ||
| 148 | } | ||
| 149 | |||
| 150 | // Per il comando "porky". | ||
| 151 | // Ancora meno che per "bier". | ||
| 152 | else if (comando.equalsIgnoreCase("porky")) { | ||
| 153 | System.out.println ("Porky è un grande"); | ||
| 154 | System.out.println ("Per maggiori informazioni visita il sito"); | ||
| 155 | return "http://kakati.forumfree.net/"; | ||
| 156 | } | ||
| 157 | |||
| 158 | // Il comando "xxx" ha funzioni analoghe a bier. | ||
| 159 | else if (comando.equalsIgnoreCase("xxx")) { | ||
| 160 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "ha incontrato una bella robottina..."); | ||
| 161 | return "*Censura*"; | ||
| 162 | } | ||
| 163 | |||
| 164 | // "dance" setta tutte le variabili "statoParte" a false... | ||
| 165 | else if (comando.equalsIgnoreCase("dance")) { | ||
| 166 | |||
| 167 | System.out.println ("Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + " stia ballando..."); | ||
| 168 | System.out.println ("Il robottino ha smesso di ballare"); | ||
| 169 | |||
| 170 | //...con questo ciclo for | ||
| 171 | for (int i = 0; i < 4; i++) { | ||
| 172 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 173 | } | ||
| 174 | |||
| 175 | return "Il robottino " + nomeRobot.elementAt(this.robotIndex) + "si è fermato ed è tornato nella posizione originale"; | ||
| 176 | |||
| 177 | // Per il comando "newrobot", che crea un nuovo robottino. | ||
| 178 | } | ||
| 179 | else if (comando.equalsIgnoreCase("newrobot")) { | ||
| 180 | |||
| 181 | // Aggiunge un elemento a "pdrA" con il metodo "addElement", della classe Vector. | ||
| 182 | // È stata necessaria la dicitura this. per modificare realmente il vettore. | ||
| 183 | // Se non lo avessi fatto non sarebbe successo, in quanto i metodi operano | ||
| 184 | // su i valori e non sulle variabili/oggetti. | ||
| 185 | this.pdrA.addElement(pdrB); | ||
| 186 | |||
| 187 | // Aggiungo le 4 parti del robot. | ||
| 188 | // Forse avete già notato (ma quì sono più evidenti) alcuni cast che ho fatto: | ||
| 189 | // sono per far si che il compilatore capisca che il metodo viene invocato da un oggetto | ||
| 190 | // della classe vector, che senza cast considererebbe della classe Object. | ||
| 191 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftArm); | ||
| 192 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightArm); | ||
| 193 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftLeg); | ||
| 194 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightLeg); | ||
| 195 | |||
| 196 | // Semplice output con richiesta di nome per il nuovo robottino. | ||
| 197 | System.out.println ("È stato creato un nuovo robot. Vuoi dare un nome al nuovo robot?"); | ||
| 198 | System.out.println ("Inserisci il nuovo nome e premi INVIO oppure lascia vuoto e premi INVIO"); | ||
| 199 | |||
| 200 | String newName = sc2.nextLine(); | ||
| 201 | |||
| 202 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 203 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 204 | |||
| 205 | this.nomeRobot.addElement(newName); | ||
| 206 | |||
| 207 | return "È stato creato il robottino " + newName; | ||
| 208 | } | ||
| 209 | |||
| 210 | // Il comando "deleterobot", per eliminare un robot. | ||
| 211 | else if (comando.equalsIgnoreCase("deleterobot")) { | ||
| 212 | |||
| 213 | // Se c'è più di un robot esegue l'eliminazione. | ||
| 214 | if (pdrA.size()>1) { | ||
| 215 | System.out.println ("Quale robottino vuoi eliminare?"); | ||
| 216 | System.out.println (""); | ||
| 217 | |||
| 218 | // Con un ciclo for scrive i nomi di tutti i robot preceduti da un numero in sequenza. | ||
| 219 | // Il numero è il corrispondente del loro indice di vettore. | ||
| 220 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 221 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 222 | } | ||
| 223 | |||
| 224 | // Dà le istruzioni all'utente affinché capisca come eliminare un robot. | ||
| 225 | System.out.println (""); | ||
| 226 | System.out.println("Scegliere il robottino da eliminare digitando il numero corrispondente e premendo INVIO"); | ||
| 227 | System.out.println("Digitare un qualunque altro numero e premere INVIO per annullare"); | ||
| 228 | |||
| 229 | // Riceve in input il numero e ne assegna il valore alla variabile "num". | ||
| 230 | int num = sc2.nextInt(); | ||
| 231 | |||
| 232 | // Elimina gli elementi corrispondenti al robottino (nome e robot) dai | ||
| 233 | // rispettivi vettori con il metodo "removeElementAt" della classe Vector. | ||
| 234 | if (num<this.pdrA.size()) { | ||
| 235 | this.pdrA.removeElementAt(num); | ||
| 236 | this.nomeRobot.removeElementAt(num); | ||
| 237 | return "È stato eliminato il robottino numero " + num; | ||
| 238 | } | ||
| 239 | |||
| 240 | // Se il numero ricevuto in input è superiore all'indice dei robot | ||
| 241 | // non elimina alcun robot. | ||
| 242 | else return "Operazione annullata"; | ||
| 243 | } | ||
| 244 | |||
| 245 | // Se c'è solo un robot non esegue l'eliminazione. | ||
| 246 | else return "Hai solo un robottino, non puoi eliminarlo!"; | ||
| 247 | } | ||
| 248 | |||
| 249 | // Il comando "changerobot" per cambiare il robot a cui dare le istruzioni | ||
| 250 | else if (comando.equalsIgnoreCase("changerobot")) { | ||
| 251 | |||
| 252 | // L'esecuzione è simile a quella per il comando "deleterobot", con la differenza che il robot non viene eliminato | ||
| 253 | // ma viene semplicemente cambiato il valore della variabile "robotIndex". | ||
| 254 | if (pdrA.size()>1) { | ||
| 255 | System.out.println ("A quale robottino vuoi dare i comandi?"); | ||
| 256 | System.out.println (""); | ||
| 257 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 258 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 259 | } | ||
| 260 | System.out.println (""); | ||
| 261 | System.out.println ("Digita il numero corrispondente alla tua scelta e premi INVIO"); | ||
| 262 | int newIndex = sc2.nextInt(); | ||
| 263 | |||
| 264 | // Prima di cambiare valore alla variabile di indice verifica che il numero sia valido. | ||
| 265 | if (newIndex<this.pdrA.size()) { | ||
| 266 | this.robotIndex = newIndex; | ||
| 267 | return "È stato selezionato il robottino numero " + this.robotIndex + ": " + this.nomeRobot.elementAt | ||
| 268 | (this.robotIndex); | ||
| 269 | } | ||
| 270 | |||
| 271 | // Se non lo è non esegue l'assegnamento. | ||
| 272 | else return "Numero non valido"; | ||
| 273 | } | ||
| 274 | else { | ||
| 275 | return "Hai solo un robottino, non puoi cambiarlo con un altro!"; | ||
| 276 | } | ||
| 277 | } | ||
| 278 | |||
| 279 | // Il comando "robotlist" visualizza una lista dei robot presenti. | ||
| 280 | else if (comando.equalsIgnoreCase("robotlist")) { | ||
| 281 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 282 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 283 | } | ||
| 284 | return ""; | ||
| 285 | } | ||
| 286 | |||
| 287 | // Il comando "l", per la legenda, visualizza la lista dei comandi con relativa descrizione. | ||
| 288 | else if (comando.equalsIgnoreCase("l")) { | ||
| 289 | System.out.println ("Legenda comandi"); | ||
| 290 | System.out.println (""); | ||
| 291 | System.out.println ("Comandi relativi agli arti"); | ||
| 292 | System.out.println (""); | ||
| 293 | System.out.println ("LeftArmMove: cambia la posizione corrente del braccio sinistro del robot"); | ||
| 294 | System.out.println ("RightArmMove: cambia la posizione corrente del braccio destro del robot"); | ||
| 295 | System.out.println ("LeftLegMove: cambia la posizione corrente della gamba sinistra del robot"); | ||
| 296 | System.out.println ("RightLegMove: cambia la posizione corrente della gamba destra del robot"); | ||
| 297 | System.out.println ("LeftArmOn: se il braccio sinistro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 298 | System.out.println ("RightArmOn: se il braccio destro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 299 | System.out.println ("LeftLegOn: se la gamba sinistra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 300 | System.out.println ("RightLegOn: se la gamba destra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 301 | System.out.println ("LeftArmOff: se il braccio sinistro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 302 | System.out.println ("RightArmOff: se il braccio destro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 303 | System.out.println ("LeftLegOff: se la gamba sinistra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 304 | System.out.println ("RightLegOff: se la gamba destra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 305 | System.out.println (""); | ||
| 306 | System.out.println ("Altri comandi:"); | ||
| 307 | System.out.println (""); | ||
| 308 | System.out.println ("NewRobot: aggiunge un nuovo robot"); | ||
| 309 | System.out.println ("ChangeRobot: cambia il robot attuale"); | ||
| 310 | System.out.println ("RobotList: visualizza la lista dei robot"); | ||
| 311 | System.out.println ("Rename: rinomina il robottino"); | ||
| 312 | System.out.println (""); | ||
| 313 | System.out.println ("Comandi a sorpresa:"); | ||
| 314 | System.out.println (""); | ||
| 315 | System.out.println ("Exploud"); | ||
| 316 | System.out.println ("Bier"); | ||
| 317 | System.out.println ("Porky"); | ||
| 318 | System.out.println ("xxx"); | ||
| 319 | System.out.println ("dance"); | ||
| 320 | System.out.println (""); | ||
| 321 | System.out.println ("Exit: esci dal programma"); | ||
| 322 | |||
| 323 | return ""; | ||
| 324 | |||
| 325 | } | ||
| 326 | |||
| 327 | // Se il comando è exit, non viene eseguita nessuna operazione (tranne restituire una stringa vuota) | ||
| 328 | // Perché il ciclo do-while nel metodo main, appena verificherà la condizione che il comando è | ||
| 329 | // uguale a "exit", terminerà da solo l'esecuzione del programma. | ||
| 330 | else if (comando.equalsIgnoreCase("exit")) return ""; | ||
| 331 | |||
| 332 | // Se l'input non è tra i comandi prestabiliti, visualizza la seguente scritta sullo schermo. | ||
| 333 | else | ||
| 334 | System.out.println ("Comando non riconosciuto - digitare l per una legenda dei comandi disponibili"); | ||
| 335 | System.out.println (""); | ||
| 336 | |||
| 337 | // Quì di seguito viene chiarito l'utilizzo di "contatore" e "sta[]". | ||
| 338 | // Per ogni varibile "statoParte" che ha valore true, contatore viene incrementato | ||
| 339 | // e l'elemento successivo dell'array "stat[]" assume il valore della stringa corrispondente. | ||
| 340 | for (int i = 0, j = 0; i < 4; i++) { | ||
| 341 | if (((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte) { | ||
| 342 | contatore += 1; | ||
| 343 | stat[j++] = ((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).stringaParte; | ||
| 344 | } | ||
| 345 | } | ||
| 346 | |||
| 347 | // La restituzione finale delle frasi, con uno switch che a seconda del valore di contatore | ||
| 348 | // restituisce una frase o l'altra. | ||
| 349 | switch (contatore) { | ||
| 350 | case 0: | ||
| 351 | Return = "Comunque il robottino " + nomeRobot.elementAt(this.robotIndex) + "non sta facendo niente"; | ||
| 352 | break; | ||
| 353 | case 1: | ||
| 354 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + "."; | ||
| 355 | break; | ||
| 356 | case 2: | ||
| 357 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + " e " + stat[1] + "."; | ||
| 358 | break; | ||
| 359 | case 3: | ||
| 360 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + ", " + stat[1] + " e " + stat[2] + "."; | ||
| 361 | break; | ||
| 362 | case 4: | ||
| 363 | Return = "Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + "abbia " + stat[0] + ", " + stat[1] + ", " + stat[2] + " e " + stat[3] + "."; | ||
| 364 | break; | ||
| 365 | } | ||
| 366 | return Return; | ||
| 367 | } | ||
| 368 | //Fine del metodo Azioni | ||
| 369 | } | ||
diff --git a/robottino/all_versions/v2.2/src/RobottinoMain/Robottino.java b/robottino/all_versions/v2.2/src/RobottinoMain/Robottino.java new file mode 100755 index 0000000..37e2dff --- /dev/null +++ b/robottino/all_versions/v2.2/src/RobottinoMain/Robottino.java | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | // Robottino versione 2.2 | ||
| 2 | // Da questa versione illustrerò tutte le parti del programma con dei commenti come questo. | ||
| 3 | |||
| 4 | // Dichiaro che questa classe fa parte del package RobottinoMain, che verrà poi importato | ||
| 5 | // dalle classi che dovranno interagire con essa. | ||
| 6 | package RobottinoMain; | ||
| 7 | |||
| 8 | // Importo le librerie iniziali: | ||
| 9 | // java.Util.Scanner per gestire gli input da tastiera. | ||
| 10 | import java.util.Scanner; | ||
| 11 | |||
| 12 | // java.util.Vector serve a gestire i vettori. | ||
| 13 | // I vettori sono come array, ma hanno due differenze principali: | ||
| 14 | // 1) la loro lunghezza può variare durante l'esecuzione del programma | ||
| 15 | // (per questo li ho preferiti agli array); | ||
| 16 | // 2) possono contenere soltanto oggetti, e non tipi primitivi. | ||
| 17 | import java.util.Vector; | ||
| 18 | |||
| 19 | // Questo è il package di utility da me creato per semplificare l'utilizzo degli elementi di altre classi | ||
| 20 | // (Grafica, PartiDelRobot). Nelle versioni precedenti c'erano solo le classi Robottino | ||
| 21 | // e PartiDelRobot, percui avevo deciso di far sì che una fosse derivata dall'altra. | ||
| 22 | import RobottinoUtils.*; | ||
| 23 | |||
| 24 | // Altro package da me definito. | ||
| 25 | import RobottinoAzioni.*; | ||
| 26 | |||
| 27 | // Dichiaro la classe. | ||
| 28 | public class Robottino { | ||
| 29 | |||
| 30 | // Istanzio anche le classi Robottino e RobottinoAzioni, per poter avere accesso agli elementi non-statici. | ||
| 31 | static Robottino robottino = new Robottino(); | ||
| 32 | static RobottinoAzioni robottinoazioni = new RobottinoAzioni(); | ||
| 33 | |||
| 34 | // Istanzio la classe Thread per poter utilizzare il metodo sleep(int millisecondi) | ||
| 35 | // che in un metodo dell'interfaccia WindowListener, overridato nella classe Listener | ||
| 36 | // servirà a mettere il programma in uno stato di pausa. | ||
| 37 | // Sarebbe comunque possibile invocarlo, ma così sarà più facile da modificare in futuro. | ||
| 38 | public static Thread threadMain; | ||
| 39 | |||
| 40 | // Inizio del metodo main... | ||
| 41 | public static void main(String[] args) { | ||
| 42 | |||
| 43 | threadMain = new Thread(Thread.currentThread()); | ||
| 44 | |||
| 45 | // Aggiungo gli elementi ai vettori. | ||
| 46 | // non potevo farlo prima, poiché al di fuori di un metodo è possibile soltanto | ||
| 47 | // dichiarare oggetti/variabili (e inizializzarli) o dichiarare un metodo | ||
| 48 | // e in RobottinoAzioni è presente solo il metodo Azioni che viene richiamato più volte. | ||
| 49 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.leftArm); | ||
| 50 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.rightArm); | ||
| 51 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.leftLeg); | ||
| 52 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.rightLeg); | ||
| 53 | RobottinoAzioni.pdrA.addElement(RobottinoAzioni.pdrB); | ||
| 54 | RobottinoAzioni.nomeRobot.addElement(""); | ||
| 55 | |||
| 56 | // Istanzio la classe Scanner per poter ricevere input | ||
| 57 | Scanner sc = new Scanner(System.in); | ||
| 58 | |||
| 59 | // Dichiaro la variabile comando che memorizzerà l'input dell'utente | ||
| 60 | String comando; | ||
| 61 | |||
| 62 | // Crea la finestra tramite un'istanza della classe Grafica, del package RobottinoUtils | ||
| 63 | Grafica finestra = new Grafica(); | ||
| 64 | |||
| 65 | // Output iniziale nellla shell | ||
| 66 | System.out.println ("**********************************************"); | ||
| 67 | System.out.println ("**********************************************"); | ||
| 68 | System.out.println ("*************Programma interattivo************"); | ||
| 69 | System.out.println ("**********************************************"); | ||
| 70 | System.out.println ("***Software realizzato da Sebastiano Tronto***"); | ||
| 71 | System.out.println ("**********************************************"); | ||
| 72 | System.out.println ("**********************************************"); | ||
| 73 | System.out.println ("Questo programma simula un robot al quale ven-"); | ||
| 74 | System.out.println ("gono assegnati ordini tramite comandi, simil-" ); | ||
| 75 | System.out.println ("mente a quanto bisognava fare con i computer " ); | ||
| 76 | System.out.println ("alcuni anni fa." ); | ||
| 77 | System.out.println ("Dato che all'epoca i comandi che dovevano es-" ); | ||
| 78 | System.out.println ("sere dati erano (e sono tutt'ora) in similin-" ); | ||
| 79 | System.out.println ("glese, ho cercato di mantenerli tali." ); | ||
| 80 | System.out.println ("Il programma non fa distinzioni tra lettere" ); | ||
| 81 | System.out.println ("maiuscole o minuscole." ); | ||
| 82 | System.out.println ("da questa versione (2.2) sono disponibili ef-" ); | ||
| 83 | System.out.println ("fetti grafici minimali e totalmente inutili." ); | ||
| 84 | System.out.println ("" ); | ||
| 85 | System.out.println ("Digita un comando e premi INVIO" ); | ||
| 86 | System.out.println ("l = legenda comandi" ); | ||
| 87 | System.out.println (""); | ||
| 88 | |||
| 89 | // Inizio del ciclo do-while che fa in modo di ricevere input ed eseguire il metodo "Azioni" | ||
| 90 | // fintando che il comando non è exit. | ||
| 91 | do { | ||
| 92 | |||
| 93 | // Inizializza la stringa comando con il valore dell'input. | ||
| 94 | comando = sc.nextLine(); | ||
| 95 | System.out.println (""); | ||
| 96 | |||
| 97 | // Esegue il metodo "Azioni" passando come argomenti il comando e i due vettori. | ||
| 98 | System.out.println (robottinoazioni.Azioni(comando, RobottinoAzioni.nomeRobot, RobottinoAzioni.pdrA)); | ||
| 99 | System.out.println (""); | ||
| 100 | } while ( !(comando.equalsIgnoreCase("exit")) ); | ||
| 101 | |||
| 102 | // Al termine del metodo main invoco il metodo "System.exit" per terminare completamente l'esecuzione del programma | ||
| 103 | System.exit(0); | ||
| 104 | } | ||
| 105 | // Fine del metodo main. | ||
| 106 | } | ||
| 107 | |||
| 108 | |||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 | |||
| 114 | |||
| 115 | |||
diff --git a/robottino/all_versions/v2.2/src/RobottinoUtils/Grafica.java b/robottino/all_versions/v2.2/src/RobottinoUtils/Grafica.java new file mode 100755 index 0000000..25574a3 --- /dev/null +++ b/robottino/all_versions/v2.2/src/RobottinoUtils/Grafica.java | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. | ||
| 2 | package RobottinoUtils; | ||
| 3 | |||
| 4 | // Importo i package standard relativi al funzionamento delle finestre e della grafica in generale. | ||
| 5 | import java.awt.*; | ||
| 6 | |||
| 7 | // E i package RobottinoAzioni e RobottinoUtils da me definiti. | ||
| 8 | import RobottinoAzioni.*; | ||
| 9 | import RobottinoUtils.Listener; | ||
| 10 | |||
| 11 | // La classe è una sottoclasse di Frame per poter sfruttare gli effetti grafici | ||
| 12 | // ma implementa anche l'interfaccia WindowListener, necessaria per gestire gli eventi collegati alle finestre | ||
| 13 | // (riduzione a icona, chiusura...); per questo devo successivamente ridefinire tutti i | ||
| 14 | // metodi dell'interfaccia. | ||
| 15 | public class Grafica extends Frame { | ||
| 16 | |||
| 17 | // Creo un'istanza della classe Listener che userò come listener per gli eventi. | ||
| 18 | public static Listener listener; | ||
| 19 | |||
| 20 | // Il costruttore senza argomenti. | ||
| 21 | public Grafica () { | ||
| 22 | |||
| 23 | // Il metodo "setBounds" posiziona e dimensiona la finestra. | ||
| 24 | setBounds (this.orizzontale, this.verticale, this.larghezza, this.altezza); | ||
| 25 | |||
| 26 | // "setTitle" per il titolo della finestra. | ||
| 27 | setTitle ("Robottino v2.2"); | ||
| 28 | |||
| 29 | // "setVisible" per poterla visualizzare. | ||
| 30 | setVisible (true); | ||
| 31 | |||
| 32 | // E addWindowListener per l'ascoltatore (listener). | ||
| 33 | listener = new Listener(); | ||
| 34 | addWindowListener (listener); | ||
| 35 | } | ||
| 36 | |||
| 37 | // Questo costruttore permette di modificare la posizione o la dimensione della finestra | ||
| 38 | // rispetto al predefinito. | ||
| 39 | public Grafica (int orizzontale, int verticale, int larghezza, int altezza) { | ||
| 40 | this.orizzontale =orizzontale; | ||
| 41 | this.verticale = verticale; | ||
| 42 | this.larghezza = larghezza; | ||
| 43 | this.altezza = altezza; | ||
| 44 | setBounds (this.orizzontale, this.verticale, this.larghezza, this.altezza); | ||
| 45 | setTitle ("Robottino v2.2"); | ||
| 46 | setVisible (true); | ||
| 47 | listener = new Listener(); | ||
| 48 | addWindowListener (listener); | ||
| 49 | } | ||
| 50 | |||
| 51 | // Le variabili pubbliche di classe per il metodo "setBounds". | ||
| 52 | public int orizzontale = 0; | ||
| 53 | public int verticale = 0; | ||
| 54 | public int larghezza = 500; | ||
| 55 | public int altezza = 500; | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | |||
diff --git a/robottino/all_versions/v2.2/src/RobottinoUtils/Listener.java b/robottino/all_versions/v2.2/src/RobottinoUtils/Listener.java new file mode 100755 index 0000000..7ff51d6 --- /dev/null +++ b/robottino/all_versions/v2.2/src/RobottinoUtils/Listener.java | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | // Questa classe è il listener per gli eventi relativi alle finestre. | ||
| 2 | // Dichiaro che farà parte del package RobottinoUtils | ||
| 3 | package RobottinoUtils; | ||
| 4 | |||
| 5 | // Importo i package necessari. | ||
| 6 | import java.awt.event.*; | ||
| 7 | import RobottinoMain.*; | ||
| 8 | |||
| 9 | public class Listener implements WindowListener { | ||
| 10 | |||
| 11 | // Ridefinisco i metodi dell'interfaccia WindowListener: | ||
| 12 | // Metodo invocato quando la finestra è stata chiusa: | ||
| 13 | public void windowClosed (WindowEvent evt) { | ||
| 14 | |||
| 15 | // Invoco il metodo sleep(int millisecondi) per mettere il programma in uno stato di attesa | ||
| 16 | // di durata pari ai millisecondi indicati come argomento. | ||
| 17 | System.out.println("La finestra è stata chiusa, il programma terminarà fra 3 secondi"); | ||
| 18 | try { | ||
| 19 | Robottino.threadMain.sleep(1000); | ||
| 20 | } catch (Exception e) { e.printStackTrace(); } | ||
| 21 | System.out.println("2"); | ||
| 22 | try { | ||
| 23 | Robottino.threadMain.sleep(1000); | ||
| 24 | } catch (Exception e) { e.printStackTrace(); } | ||
| 25 | System.out.println("1"); | ||
| 26 | try { | ||
| 27 | Robottino.threadMain.sleep(1000); | ||
| 28 | } catch (Exception e) { e.printStackTrace(); } | ||
| 29 | System.out.println("Programma terminato"); | ||
| 30 | System.exit(0); | ||
| 31 | } | ||
| 32 | |||
| 33 | // Metodo invocato quando la finestra è in fase di chiusura: | ||
| 34 | public void windowClosing (WindowEvent evt) { | ||
| 35 | System.out.println ("Chiusura finestra in corso"); | ||
| 36 | evt.getWindow().dispose(); | ||
| 37 | } | ||
| 38 | |||
| 39 | // Metodo invocato quando una finestra viene ridotta a icona: | ||
| 40 | public void windowIconified (WindowEvent evt) { | ||
| 41 | System.out.println("La finestra è stata ridotta a icona"); | ||
| 42 | } | ||
| 43 | |||
| 44 | // Metodo invocato quando una finestra ridotta a icona viene ingrandita: | ||
| 45 | public void windowDeiconified (WindowEvent evt) { | ||
| 46 | System.out.println("La finestra ridotta a icona è stata ingrandita"); | ||
| 47 | } | ||
| 48 | |||
| 49 | // Metodo invocato quando una finestra viene aperta: | ||
| 50 | public void windowOpened (WindowEvent evt) {} | ||
| 51 | |||
| 52 | // Metodo invocato quando una finestra diventa attiva: | ||
| 53 | public void windowActivated (WindowEvent evt) {} | ||
| 54 | |||
| 55 | // Metodo invocato quando una finestra viene disattivata: | ||
| 56 | public void windowDeactivated (WindowEvent evt) {} | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | |||
diff --git a/robottino/all_versions/v2.2/src/RobottinoUtils/PartiDelRobot.java b/robottino/all_versions/v2.2/src/RobottinoUtils/PartiDelRobot.java new file mode 100755 index 0000000..d6cf869 --- /dev/null +++ b/robottino/all_versions/v2.2/src/RobottinoUtils/PartiDelRobot.java | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. | ||
| 2 | package RobottinoUtils; | ||
| 3 | |||
| 4 | // Dichiaro la classe. | ||
| 5 | public class PartiDelRobot { | ||
| 6 | |||
| 7 | // Creo un costruttore senza argomenti. | ||
| 8 | // Se non lo facessi sarei obbligato a passare gli argomenti | ||
| 9 | // del secondo costruttore ogni volta che voglio istanziare la classe. | ||
| 10 | public PartiDelRobot() {} | ||
| 11 | |||
| 12 | // Il secondo costruttore riceve come argomenti un booleano che passerà il valore a "statoParte" | ||
| 13 | // e una stringa che passa il valore a "stringaParte". | ||
| 14 | public PartiDelRobot(boolean b, String s) { | ||
| 15 | this.stringaParte = s; | ||
| 16 | this.statoParte = b; | ||
| 17 | } | ||
| 18 | |||
| 19 | // Infine le due variabili pubbliche della classe. | ||
| 20 | public String stringaParte; | ||
| 21 | public boolean statoParte; | ||
| 22 | } | ||
diff --git a/robottino/all_versions/v2.3/Esegui.bat b/robottino/all_versions/v2.3/Esegui.bat new file mode 100755 index 0000000..d413ed8 --- /dev/null +++ b/robottino/all_versions/v2.3/Esegui.bat | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | cd ./bin | ||
| 2 | java RobottinoMain/Robottino | ||
| 3 | cd | ||
diff --git a/robottino/all_versions/v2.3/Esegui.sh b/robottino/all_versions/v2.3/Esegui.sh new file mode 100755 index 0000000..d413ed8 --- /dev/null +++ b/robottino/all_versions/v2.3/Esegui.sh | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | cd ./bin | ||
| 2 | java RobottinoMain/Robottino | ||
| 3 | cd | ||
diff --git a/robottino/all_versions/v2.3/Readme.txt b/robottino/all_versions/v2.3/Readme.txt new file mode 100755 index 0000000..52d532c --- /dev/null +++ b/robottino/all_versions/v2.3/Readme.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Il programma necessita della JVM (Java Virtual Machine) per funzionare correttamente | ||
| 2 | |||
| 3 | Se si usano sistemi Windows aprire il file Esegui.bat | ||
| 4 | Se si usano sistemi Unix dare i permessi necessari ed eseguire il file Esegui.sh | ||
| 5 | Se si usano altri sistemi aprire una shell e digitare i comandi | ||
| 6 | |||
| 7 | cd <percorsoFile>/bin | ||
| 8 | java Robottino | ||
| 9 | |||
| 10 | dove percorsoFile è il percorso di questo file. | ||
diff --git a/robottino/all_versions/v2.3/bin/RobottinoAzioni/RobottinoAzioni.class b/robottino/all_versions/v2.3/bin/RobottinoAzioni/RobottinoAzioni.class new file mode 100755 index 0000000..d8aeb55 --- /dev/null +++ b/robottino/all_versions/v2.3/bin/RobottinoAzioni/RobottinoAzioni.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.3/bin/RobottinoMain/Robottino.class b/robottino/all_versions/v2.3/bin/RobottinoMain/Robottino.class new file mode 100755 index 0000000..58413c9 --- /dev/null +++ b/robottino/all_versions/v2.3/bin/RobottinoMain/Robottino.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.3/bin/RobottinoUtils/Grafica.class b/robottino/all_versions/v2.3/bin/RobottinoUtils/Grafica.class new file mode 100755 index 0000000..7ad96fe --- /dev/null +++ b/robottino/all_versions/v2.3/bin/RobottinoUtils/Grafica.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.3/bin/RobottinoUtils/Listener.class b/robottino/all_versions/v2.3/bin/RobottinoUtils/Listener.class new file mode 100755 index 0000000..3ddc989 --- /dev/null +++ b/robottino/all_versions/v2.3/bin/RobottinoUtils/Listener.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.3/bin/RobottinoUtils/PartiDelRobot.class b/robottino/all_versions/v2.3/bin/RobottinoUtils/PartiDelRobot.class new file mode 100755 index 0000000..fcc8e9e --- /dev/null +++ b/robottino/all_versions/v2.3/bin/RobottinoUtils/PartiDelRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v2.3/src/RobottinoAzioni/RobottinoAzioni.java b/robottino/all_versions/v2.3/src/RobottinoAzioni/RobottinoAzioni.java new file mode 100755 index 0000000..27d568a --- /dev/null +++ b/robottino/all_versions/v2.3/src/RobottinoAzioni/RobottinoAzioni.java | |||
| @@ -0,0 +1,397 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoAzioni, che verrà poi importato dalle classi Listener e Grafica. | ||
| 2 | package RobottinoAzioni; | ||
| 3 | |||
| 4 | // Anche qui impoerto i package necessari. | ||
| 5 | // java.util.Scanner gestisce gli input da tastiera | ||
| 6 | import java.util.Scanner; | ||
| 7 | |||
| 8 | // java.util.Vector | ||
| 9 | import java.util.Vector; | ||
| 10 | |||
| 11 | // Package definito da me. | ||
| 12 | import RobottinoUtils.*; | ||
| 13 | |||
| 14 | public class RobottinoAzioni { | ||
| 15 | |||
| 16 | // Creo gli oggetti statici che riempiranno il vettore pdrA: | ||
| 17 | // pdrA è un vettore multidimensionale che a sua volta contiene vettori | ||
| 18 | // (il primo si chiama pdrB, i successivi non avranno nome) che coontengono | ||
| 19 | // 4 istanze di PartiDelRobot, cioè i 4 arti del robot. | ||
| 20 | // Poi creo un vettore che conterrà i nomi dei robot. | ||
| 21 | // Creo il vettore principale... | ||
| 22 | public static Vector pdrA = new Vector(1); | ||
| 23 | |||
| 24 | // ...e il "sottovettore" come istanze della classe Vector | ||
| 25 | public static Vector pdrB = new Vector(4); | ||
| 26 | |||
| 27 | // Creo le quattro istanze di PartidelRobot utilizzando l'apposito costruttore | ||
| 28 | // passo a tutte una stringa e un valore boleano che determina lo stato | ||
| 29 | // (alzato/a se true, abbassato/a se false). | ||
| 30 | public static PartiDelRobot leftArm = new PartiDelRobot(false, "il braccio sinistro alzato"); | ||
| 31 | public static PartiDelRobot rightArm = new PartiDelRobot(false, "il braccio destro alzato"); | ||
| 32 | public static PartiDelRobot leftLeg = new PartiDelRobot(false, "la gamba sinistra alzata"); | ||
| 33 | public static PartiDelRobot rightLeg = new PartiDelRobot(false, "la gamba destra alzata"); | ||
| 34 | |||
| 35 | // Il vettore nomeRobot per i nomi | ||
| 36 | // il vettore può contenere stringhe, poichè non sono tipi primitivi ma oggetti della classe String | ||
| 37 | public static Vector nomeRobot = new Vector(1); | ||
| 38 | |||
| 39 | // La variabile robotIndex serve a tenere in memoria su quale robot si sta operando: | ||
| 40 | // in seguito verrà usata quando l'utente deciderà di creare più di un robot | ||
| 41 | // e poi di dare comandi a uno o all'altro/i. | ||
| 42 | int robotIndex = 0; | ||
| 43 | |||
| 44 | // Dichiarazione del metodo Azioni. | ||
| 45 | public String Azioni(String comando, Vector nomeRobot, Vector pdrA) { | ||
| 46 | |||
| 47 | // Crea un'istanza della classe Scanner per | ||
| 48 | // ricevere gli input nel caso in cui debba essere dato il nome | ||
| 49 | // al robottino o scelto un robottino da una lista. | ||
| 50 | Scanner sc2 = new Scanner(System.in); | ||
| 51 | |||
| 52 | // La variabile contatore memorizza il numero di variabili "PartiDelRobot.statoParte" | ||
| 53 | // che hanno valore true, ossia il numero di arti alzati di un robottino | ||
| 54 | // in modo da poter scegliere la frase giusta da dare come output | ||
| 55 | // al posto dell'immagine del robottino con tali arti alzati. | ||
| 56 | int contatore = 0; | ||
| 57 | |||
| 58 | // Questo array ha il compito di memorizzare le stringhe corrispondenti agli alzati | ||
| 59 | // per motivi simili a quelli della variabile "contatore". | ||
| 60 | String stat[] = {"", "", "", ""}; | ||
| 61 | |||
| 62 | // La stringa Return verrà successivamente modificata e restituita in alcuni casi. | ||
| 63 | String Return = "Errore - si consiglia di picchiare il programmatore"; | ||
| 64 | |||
| 65 | // Per far si che il programma non distingua tra lettere maiuscole o minuscole per quanto riguardo gli input | ||
| 66 | // è stato usato il metodo "equalsIgnoreCase" della classe String. | ||
| 67 | // I quattro casi successivi cambiano il valore della varibalie "statoParte" relativa all'arto | ||
| 68 | // Che deve mouversi (quindi cambiare la sua posizione). | ||
| 69 | if (comando.equalsIgnoreCase("leftarmmove")) | ||
| 70 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = | ||
| 71 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte; | ||
| 72 | |||
| 73 | else if (comando.equalsIgnoreCase("rightarmmove")) | ||
| 74 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = | ||
| 75 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte; | ||
| 76 | |||
| 77 | else if (comando.equalsIgnoreCase("leftlegmove")) | ||
| 78 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = | ||
| 79 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte; | ||
| 80 | |||
| 81 | else if (comando.equalsIgnoreCase("rightlegmove")) | ||
| 82 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = | ||
| 83 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte; | ||
| 84 | |||
| 85 | // I casi successivi modificano il valore della varibile analogamente ai 4 precedenti. | ||
| 86 | else if (comando.equalsIgnoreCase("leftarmon")) | ||
| 87 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = true; | ||
| 88 | |||
| 89 | else if (comando.equalsIgnoreCase("rightarmon")) | ||
| 90 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = true; | ||
| 91 | |||
| 92 | else if (comando.equalsIgnoreCase("leftlegon")) | ||
| 93 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = true; | ||
| 94 | |||
| 95 | else if (comando.equalsIgnoreCase("rightlegon")) | ||
| 96 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = true; | ||
| 97 | |||
| 98 | else if (comando.equalsIgnoreCase("leftarmoff")) | ||
| 99 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = false; | ||
| 100 | |||
| 101 | else if (comando.equalsIgnoreCase("rightarmoff")) | ||
| 102 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = false; | ||
| 103 | |||
| 104 | else if (comando.equalsIgnoreCase("leftlegoff")) | ||
| 105 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = false; | ||
| 106 | |||
| 107 | else if (comando.equalsIgnoreCase("rightlegoff")) | ||
| 108 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = false; | ||
| 109 | |||
| 110 | // Il caso successi si verica quando il comando è "exploud". | ||
| 111 | else if (comando.equalsIgnoreCase("exploud")) { | ||
| 112 | |||
| 113 | // Scrive sullo schermo la seguente frase, che comprende il nome del robottino che non è ancora stato fatto eliminare | ||
| 114 | System.out.println | ||
| 115 | ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot.elementAt(this.robotIndex) + "! Aspetta che te ne faccio un altro"); | ||
| 116 | System.out.println ("..."); | ||
| 117 | |||
| 118 | // Con un ciclo for rendo false tutte le variabili "statoParte" per far sì che il robottino sia come nuovo. | ||
| 119 | for (int i = 0; i < 4; i++) { | ||
| 120 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 121 | } | ||
| 122 | |||
| 123 | // E azzero anche il nome del robot | ||
| 124 | this.nomeRobot.setElementAt("", this.robotIndex); | ||
| 125 | |||
| 126 | return "Fatto, puoi continuare a giocare"; | ||
| 127 | } | ||
| 128 | |||
| 129 | // Caso per il comando "bier". | ||
| 130 | // La reazione a questo comando è un semplice output quasi totalmente scorrelato al robottino | ||
| 131 | // se non per il fatto che appare il nome del robottino attuale. | ||
| 132 | else if (comando.equalsIgnoreCase("bier")) { | ||
| 133 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "sta trangugiando una birra..."); | ||
| 134 | System.out.println ("Buurrrrrrrrp!"); | ||
| 135 | return "La birra analcolica fa schifo!"; | ||
| 136 | } | ||
| 137 | |||
| 138 | // Per il comando "rename", rinomina. | ||
| 139 | else if (comando.equalsIgnoreCase("rename")) { | ||
| 140 | |||
| 141 | System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot.elementAt(this.robotIndex)); | ||
| 142 | System.out.println ("Digita il nuovo nome e premi INVIO per coninuare"); | ||
| 143 | |||
| 144 | // Cambia il nome del robottino attuale con quello dell'input. | ||
| 145 | this.nomeRobot.setElementAt(sc2.nextLine(), this.robotIndex); | ||
| 146 | |||
| 147 | // Se il nome non è vuoto, aggiunge un carattere di spazio per migliorare la visualizzazione nelle frasi di output. | ||
| 148 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 149 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 150 | |||
| 151 | // Semplice output con il nuovo nome. | ||
| 152 | return "Ora il robottino si chiama " + nomeRobot.elementAt(this.robotIndex); | ||
| 153 | } | ||
| 154 | |||
| 155 | // Per il comando "porky". | ||
| 156 | // Ancora meno che per "bier". | ||
| 157 | else if (comando.equalsIgnoreCase("porky")) { | ||
| 158 | System.out.println ("Porky è un grande"); | ||
| 159 | System.out.println ("Per maggiori informazioni visita il sito"); | ||
| 160 | return "http://kakati.forumfree.net/"; | ||
| 161 | } | ||
| 162 | |||
| 163 | // Il comando "xxx" ha funzioni analoghe a bier. | ||
| 164 | else if (comando.equalsIgnoreCase("xxx")) { | ||
| 165 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "ha incontrato una bella robottina..."); | ||
| 166 | return "*Censura*"; | ||
| 167 | } | ||
| 168 | |||
| 169 | // "dance" setta tutte le variabili "statoParte" a false... | ||
| 170 | else if (comando.equalsIgnoreCase("dance")) { | ||
| 171 | |||
| 172 | System.out.println ("Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + " stia ballando..."); | ||
| 173 | System.out.println ("Il robottino ha smesso di ballare"); | ||
| 174 | |||
| 175 | //...con questo ciclo for | ||
| 176 | for (int i = 0; i < 4; i++) { | ||
| 177 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 178 | } | ||
| 179 | |||
| 180 | return "Il robottino " + nomeRobot.elementAt(this.robotIndex) + "si è fermato ed è tornato nella posizione originale"; | ||
| 181 | |||
| 182 | // Per il comando "newrobot", che crea un nuovo robottino. | ||
| 183 | } | ||
| 184 | else if (comando.equalsIgnoreCase("newrobot")) { | ||
| 185 | |||
| 186 | // Aggiunge un elemento a "pdrA" con il metodo "addElement", della classe Vector. | ||
| 187 | // È stata necessaria la dicitura this. per modificare realmente il vettore. | ||
| 188 | // Se non lo avessi fatto non sarebbe successo, in quanto i metodi operano | ||
| 189 | // su i valori e non sulle variabili/oggetti. | ||
| 190 | this.pdrA.addElement(pdrB); | ||
| 191 | |||
| 192 | // Aggiungo le 4 parti del robot. | ||
| 193 | // Forse avete già notato (ma quì sono più evidenti) alcuni cast che ho fatto: | ||
| 194 | // sono per far si che il compilatore capisca che il metodo viene invocato da un oggetto | ||
| 195 | // della classe vector, che senza cast considererebbe della classe Object. | ||
| 196 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftArm); | ||
| 197 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightArm); | ||
| 198 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftLeg); | ||
| 199 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightLeg); | ||
| 200 | |||
| 201 | // Semplice output con richiesta di nome per il nuovo robottino. | ||
| 202 | System.out.println ("È stato creato un nuovo robot. Vuoi dare un nome al nuovo robot?"); | ||
| 203 | System.out.println ("Inserisci il nuovo nome e premi INVIO oppure lascia vuoto e premi INVIO"); | ||
| 204 | |||
| 205 | String newName = sc2.nextLine(); | ||
| 206 | |||
| 207 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 208 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 209 | |||
| 210 | this.nomeRobot.addElement(newName); | ||
| 211 | |||
| 212 | return "È stato creato il robottino " + newName; | ||
| 213 | } | ||
| 214 | |||
| 215 | // Il comando "deleterobot", per eliminare un robot. | ||
| 216 | else if (comando.equalsIgnoreCase("deleterobot")) { | ||
| 217 | |||
| 218 | // Se c'è più di un robot esegue l'eliminazione. | ||
| 219 | if (pdrA.size()>1) { | ||
| 220 | System.out.println ("Quale robottino vuoi eliminare?"); | ||
| 221 | System.out.println (""); | ||
| 222 | |||
| 223 | // Con un ciclo for scrive i nomi di tutti i robot preceduti da un numero in sequenza. | ||
| 224 | // Il numero è il corrispondente del loro indice di vettore. | ||
| 225 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 226 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 227 | } | ||
| 228 | |||
| 229 | // Dà le istruzioni all'utente affinché capisca come eliminare un robot. | ||
| 230 | System.out.println (""); | ||
| 231 | System.out.println("Scegliere il robottino da eliminare digitando il numero corrispondente e premendo INVIO"); | ||
| 232 | System.out.println("Digitare un qualunque altro numero e premere INVIO per annullare"); | ||
| 233 | |||
| 234 | int num = this.pdrA.size()+1; | ||
| 235 | |||
| 236 | try { | ||
| 237 | |||
| 238 | // Riceve in input il numero e ne assegna il valore alla variabile "num". | ||
| 239 | num = sc2.nextInt(); | ||
| 240 | |||
| 241 | } catch (Exception e) { | ||
| 242 | System.out.println("Puoi inserire solo numeri"); | ||
| 243 | } | ||
| 244 | |||
| 245 | // Elimina gli elementi corrispondenti al robottino (nome e robot) dai | ||
| 246 | // rispettivi vettori con il metodo "removeElementAt" della classe Vector. | ||
| 247 | if (num<this.pdrA.size()) { | ||
| 248 | this.pdrA.removeElementAt(num); | ||
| 249 | this.nomeRobot.removeElementAt(num); | ||
| 250 | return "È stato eliminato il robottino numero " + num; | ||
| 251 | } | ||
| 252 | |||
| 253 | // Se il numero ricevuto in input è superiore all'indice dei robot | ||
| 254 | // non elimina alcun robot. | ||
| 255 | else return "Operazione annullata"; | ||
| 256 | } | ||
| 257 | |||
| 258 | // Se c'è solo un robot non esegue l'eliminazione. | ||
| 259 | else return "Hai solo un robottino, non puoi eliminarlo!"; | ||
| 260 | } | ||
| 261 | |||
| 262 | // Il comando "changerobot" per cambiare il robot a cui dare le istruzioni | ||
| 263 | else if (comando.equalsIgnoreCase("changerobot")) { | ||
| 264 | |||
| 265 | // L'esecuzione è simile a quella per il comando "deleterobot", con la differenza che il robot non viene eliminato | ||
| 266 | // ma viene semplicemente cambiato il valore della variabile "robotIndex". | ||
| 267 | if (pdrA.size()>1) { | ||
| 268 | System.out.println ("A quale robottino vuoi dare i comandi?"); | ||
| 269 | System.out.println (""); | ||
| 270 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 271 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 272 | } | ||
| 273 | System.out.println (""); | ||
| 274 | System.out.println ("Digita il numero corrispondente alla tua scelta e premi INVIO"); | ||
| 275 | |||
| 276 | int newIndex = this.pdrA.size()+1; | ||
| 277 | |||
| 278 | try { | ||
| 279 | |||
| 280 | newIndex = sc2.nextInt(); | ||
| 281 | |||
| 282 | } catch (Exception e) { | ||
| 283 | System.out.println("Puoi inserire solo numeri"); | ||
| 284 | } | ||
| 285 | |||
| 286 | // Prima di cambiare valore alla variabile di indice verifica che il numero sia valido. | ||
| 287 | if (newIndex<this.pdrA.size()) { | ||
| 288 | this.robotIndex = newIndex; | ||
| 289 | return "È stato selezionato il robottino numero " + this.robotIndex + ": " + this.nomeRobot.elementAt | ||
| 290 | (this.robotIndex); | ||
| 291 | } | ||
| 292 | |||
| 293 | // Se non lo è non esegue l'assegnamento. | ||
| 294 | else return "Numero non valido - Operazione annullata"; | ||
| 295 | } | ||
| 296 | else { | ||
| 297 | return "Hai solo un robottino, non puoi cambiarlo con un altro!"; | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | // Il comando "robotlist" visualizza una lista dei robot presenti. | ||
| 302 | else if (comando.equalsIgnoreCase("robotlist")) { | ||
| 303 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 304 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 305 | } | ||
| 306 | return ""; | ||
| 307 | } | ||
| 308 | |||
| 309 | // Il comando "l", per la legenda, visualizza la lista dei comandi con relativa descrizione. | ||
| 310 | else if (comando.equalsIgnoreCase("l")) { | ||
| 311 | System.out.println ("Legenda comandi"); | ||
| 312 | System.out.println (""); | ||
| 313 | System.out.println ("Comandi relativi agli arti"); | ||
| 314 | System.out.println (""); | ||
| 315 | System.out.println ("LeftArmMove: cambia la posizione corrente del braccio sinistro del robot"); | ||
| 316 | System.out.println ("RightArmMove: cambia la posizione corrente del braccio destro del robot"); | ||
| 317 | System.out.println ("LeftLegMove: cambia la posizione corrente della gamba sinistra del robot"); | ||
| 318 | System.out.println ("RightLegMove: cambia la posizione corrente della gamba destra del robot"); | ||
| 319 | System.out.println ("LeftArmOn: se il braccio sinistro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 320 | System.out.println ("RightArmOn: se il braccio destro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 321 | System.out.println ("LeftLegOn: se la gamba sinistra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 322 | System.out.println ("RightLegOn: se la gamba destra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 323 | System.out.println ("LeftArmOff: se il braccio sinistro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 324 | System.out.println ("RightArmOff: se il braccio destro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 325 | System.out.println ("LeftLegOff: se la gamba sinistra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 326 | System.out.println ("RightLegOff: se la gamba destra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 327 | System.out.println (""); | ||
| 328 | System.out.println ("Altri comandi:"); | ||
| 329 | System.out.println (""); | ||
| 330 | System.out.println ("NewRobot: aggiunge un nuovo robot"); | ||
| 331 | System.out.println ("ChangeRobot: cambia il robot attuale"); | ||
| 332 | System.out.println ("RobotList: visualizza la lista dei robot"); | ||
| 333 | System.out.println ("Rename: rinomina il robottino"); | ||
| 334 | System.out.println (""); | ||
| 335 | System.out.println ("Comandi a sorpresa:"); | ||
| 336 | System.out.println (""); | ||
| 337 | System.out.println ("Exploud"); | ||
| 338 | System.out.println ("Bier"); | ||
| 339 | System.out.println ("Porky"); | ||
| 340 | System.out.println ("xxx"); | ||
| 341 | System.out.println ("dance"); | ||
| 342 | System.out.println (""); | ||
| 343 | System.out.println ("Exit: esci dal programma"); | ||
| 344 | |||
| 345 | return ""; | ||
| 346 | |||
| 347 | } | ||
| 348 | |||
| 349 | // Se il comando è exit, esce dal programma. | ||
| 350 | else if (comando.equalsIgnoreCase("exit")) { | ||
| 351 | System.exit(0); | ||
| 352 | return ""; | ||
| 353 | } | ||
| 354 | |||
| 355 | // Se l'input non è tra i comandi prestabiliti, visualizza la seguente scritta sullo schermo. | ||
| 356 | else | ||
| 357 | System.out.println ("Comando non riconosciuto - digitare l per una legenda dei comandi disponibili"); | ||
| 358 | System.out.println (""); | ||
| 359 | |||
| 360 | // Quì di seguito viene chiarito l'utilizzo di "contatore" e "sta[]". | ||
| 361 | // Per ogni varibile "statoParte" che ha valore true, contatore viene incrementato | ||
| 362 | // e l'elemento successivo dell'array "stat[]" assume il valore della stringa corrispondente. | ||
| 363 | for (int i = 0, j = 0; i < 4; i++) { | ||
| 364 | if (((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte) { | ||
| 365 | contatore += 1; | ||
| 366 | stat[j++] = ((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).stringaParte; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | // La restituzione finale delle frasi, con uno switch che a seconda del valore di contatore | ||
| 371 | // restituisce una frase o l'altra. | ||
| 372 | switch (contatore) { | ||
| 373 | case 0: | ||
| 374 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"non ha nessun arto alzato"; | ||
| 375 | break; | ||
| 376 | case 1: | ||
| 377 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0] + "."; | ||
| 378 | break; | ||
| 379 | case 2: | ||
| 380 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0]+" e "+stat[1]+"."; | ||
| 381 | break; | ||
| 382 | case 3: | ||
| 383 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0]+", "+stat[1]+" e "+stat[2]+"."; | ||
| 384 | break; | ||
| 385 | case 4: | ||
| 386 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0]+", "+stat[1]+", "+stat[2]+" e "+stat[3]+". Sta per cadere! Ah no, può restare sospeso in aria"; | ||
| 387 | break; | ||
| 388 | } | ||
| 389 | return Return; | ||
| 390 | } | ||
| 391 | //Fine del metodo Azioni | ||
| 392 | } | ||
| 393 | |||
| 394 | |||
| 395 | |||
| 396 | |||
| 397 | |||
diff --git a/robottino/all_versions/v2.3/src/RobottinoMain/Robottino.java b/robottino/all_versions/v2.3/src/RobottinoMain/Robottino.java new file mode 100755 index 0000000..37471cf --- /dev/null +++ b/robottino/all_versions/v2.3/src/RobottinoMain/Robottino.java | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | // Robottino versione 2.2 | ||
| 2 | // Da questa versione illustrerò tutte le parti del programma con dei commenti come questo. | ||
| 3 | |||
| 4 | // Dichiaro che questa classe fa parte del package RobottinoMain, che verrà poi importato | ||
| 5 | // dalle classi che dovranno interagire con essa. | ||
| 6 | package RobottinoMain; | ||
| 7 | |||
| 8 | // Importo la classe Grafica per poter "costruire" una finestra. | ||
| 9 | import RobottinoUtils.Grafica; | ||
| 10 | |||
| 11 | // E il package Robottinoazioni per poterne inizializzare i vettori | ||
| 12 | import RobottinoAzioni.*; | ||
| 13 | |||
| 14 | // java.util.Vector serve a gestire i vettori. | ||
| 15 | // I vettori sono come array, ma hanno due differenze principali: | ||
| 16 | // 1) la loro lunghezza può variare durante l'esecuzione del programma | ||
| 17 | // (per questo li ho preferiti agli array); | ||
| 18 | // 2) possono contenere soltanto oggetti, e non tipi primitivi. | ||
| 19 | import java.util.Vector; | ||
| 20 | |||
| 21 | // Dichiaro la classe. | ||
| 22 | public class Robottino { | ||
| 23 | |||
| 24 | |||
| 25 | // Istanzio la classe Thread per poter utilizzare il metodo sleep(int millisecondi) | ||
| 26 | // che in un metodo dell'interfaccia WindowListener, overridato nella classe Listener | ||
| 27 | // servirà a mettere il programma in uno stato di pausa. | ||
| 28 | // Sarebbe comunque possibile invocarlo, ma così sarà più facile da modificare in futuro. | ||
| 29 | public static Thread threadMain; | ||
| 30 | |||
| 31 | // Inizio del metodo main... | ||
| 32 | public static void main(String[] args) { | ||
| 33 | |||
| 34 | threadMain = new Thread(Thread.currentThread()); | ||
| 35 | |||
| 36 | // Aggiungo gli elementi ai vettori. | ||
| 37 | // non potevo farlo prima, poiché al di fuori di un metodo è possibile soltanto | ||
| 38 | // dichiarare oggetti/variabili (e inizializzarli) o dichiarare un metodo | ||
| 39 | // e in RobottinoAzioni è presente solo il metodo Azioni che viene richiamato più volte. | ||
| 40 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.leftArm); | ||
| 41 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.rightArm); | ||
| 42 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.leftLeg); | ||
| 43 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.rightLeg); | ||
| 44 | RobottinoAzioni.pdrA.addElement(RobottinoAzioni.pdrB); | ||
| 45 | RobottinoAzioni.nomeRobot.addElement(""); | ||
| 46 | |||
| 47 | // Crea la finestra tramite un'istanza della classe Grafica, del package RobottinoUtils | ||
| 48 | Grafica finestra = new Grafica(); | ||
| 49 | |||
| 50 | // Output iniziale nellla shell | ||
| 51 | System.out.println ("**********************************************"); | ||
| 52 | System.out.println ("**********************************************"); | ||
| 53 | System.out.println ("*************Programma interattivo************"); | ||
| 54 | System.out.println ("**********************************************"); | ||
| 55 | System.out.println ("***Software realizzato da Sebastiano Tronto***"); | ||
| 56 | System.out.println ("**********************************************"); | ||
| 57 | System.out.println ("**********************************************"); | ||
| 58 | System.out.println ("Questo programma simula un robot al quale ven-"); | ||
| 59 | System.out.println ("gono assegnati ordini tramite comandi, simil-" ); | ||
| 60 | System.out.println ("mente a quanto bisognava fare con i computer " ); | ||
| 61 | System.out.println ("alcuni anni fa." ); | ||
| 62 | System.out.println ("Dato che all'epoca i comandi che dovevano es-" ); | ||
| 63 | System.out.println ("sere dati erano (e sono tutt'ora) in similin-" ); | ||
| 64 | System.out.println ("glese, ho cercato di mantenerli tali." ); | ||
| 65 | System.out.println ("Da questa versione (v2.3) i comandi devono es-"); | ||
| 66 | System.out.println ("sere dati attraverso i menu File, Modifica o " ); | ||
| 67 | System.out.println ("Azioni della finestra." ); | ||
| 68 | System.out.println ("" ); | ||
| 69 | System.out.println ("Tuttavia la reazione del robottino verrà vi-" ); | ||
| 70 | System.out.println ("sualizzata attraverso la shell." ); | ||
| 71 | System.out.println (""); | ||
| 72 | } | ||
| 73 | // Fine del metodo main. | ||
| 74 | } | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
diff --git a/robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java b/robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java new file mode 100755 index 0000000..b845a7f --- /dev/null +++ b/robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java | |||
| @@ -0,0 +1,210 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. | ||
| 2 | package RobottinoUtils; | ||
| 3 | |||
| 4 | // Importo i package standard relativi al funzionamento delle finestre e della grafica in generale. | ||
| 5 | import java.awt.*; | ||
| 6 | |||
| 7 | // E i package RobottinoAzioni e RobottinoUtils da me definiti. | ||
| 8 | import RobottinoAzioni.*; | ||
| 9 | import RobottinoUtils.Listener; | ||
| 10 | |||
| 11 | // La classe è una sottoclasse di Frame per poter sfruttare gli effetti grafici | ||
| 12 | // ma implementa anche l'interfaccia WindowListener, necessaria per gestire gli eventi collegati alle finestre | ||
| 13 | // (riduzione a icona, chiusura...); per questo devo successivamente ridefinire tutti i | ||
| 14 | // metodi dell'interfaccia. | ||
| 15 | public class Grafica extends Frame { | ||
| 16 | |||
| 17 | // Creo un'istanza della classe Listener che userò come listener per gli eventi. | ||
| 18 | public static Listener listener; | ||
| 19 | |||
| 20 | // Il costruttore senza argomenti. | ||
| 21 | public Grafica () { | ||
| 22 | |||
| 23 | // Il metodo "setBounds" posiziona e dimensiona la finestra. | ||
| 24 | setBounds (this.orizzontale, this.verticale, this.larghezza, this.altezza); | ||
| 25 | |||
| 26 | // "setTitle" per il titolo della finestra. | ||
| 27 | setTitle ("Robottino v2.2"); | ||
| 28 | |||
| 29 | // "setVisible" per poterla visualizzare. | ||
| 30 | setVisible (true); | ||
| 31 | |||
| 32 | // E addWindowListener per l'ascoltatore (listener). | ||
| 33 | listener = new Listener(); | ||
| 34 | addWindowListener (listener); | ||
| 35 | |||
| 36 | // Aggiungo la barra del menu con i vari sottomenu | ||
| 37 | setMenuBar (barraMenu); | ||
| 38 | |||
| 39 | // Il menu file. | ||
| 40 | NewRobot.addActionListener(listener); | ||
| 41 | NewRobot.setActionCommand("newrobot"); | ||
| 42 | |||
| 43 | ChangeRobot.addActionListener(listener); | ||
| 44 | ChangeRobot.setActionCommand("changerobot"); | ||
| 45 | |||
| 46 | DeleteRobot.addActionListener(listener); | ||
| 47 | DeleteRobot.setActionCommand("deleterobot"); | ||
| 48 | |||
| 49 | Exit.addActionListener(listener); | ||
| 50 | Exit.setActionCommand("exit"); | ||
| 51 | |||
| 52 | file.add(NewRobot); | ||
| 53 | file.add(ChangeRobot); | ||
| 54 | file.add(DeleteRobot); | ||
| 55 | file.addSeparator(); | ||
| 56 | file.add(Exit); | ||
| 57 | |||
| 58 | barraMenu.add(file); | ||
| 59 | |||
| 60 | // Il braccio sinistro. | ||
| 61 | LeftArmMove.addActionListener(listener); | ||
| 62 | LeftArmMove.setActionCommand("leftarmmove"); | ||
| 63 | |||
| 64 | LeftArmOn.addActionListener(listener); | ||
| 65 | LeftArmOn.setActionCommand("leftarmon"); | ||
| 66 | |||
| 67 | LeftArmOff.addActionListener(listener); | ||
| 68 | LeftArmOff.setActionCommand("leftarmoff"); | ||
| 69 | |||
| 70 | LeftArm.add(LeftArmMove); | ||
| 71 | LeftArm.add(LeftArmOn); | ||
| 72 | LeftArm.add(LeftArmOff); | ||
| 73 | |||
| 74 | // Il braccio destro. | ||
| 75 | RightArmMove.addActionListener(listener); | ||
| 76 | RightArmMove.setActionCommand("rightarmmove"); | ||
| 77 | |||
| 78 | RightArmOn.addActionListener(listener); | ||
| 79 | RightArmOn.setActionCommand("rightarmon"); | ||
| 80 | |||
| 81 | RightArmOff.addActionListener(listener); | ||
| 82 | RightArmOff.setActionCommand("rightarmoff"); | ||
| 83 | |||
| 84 | RightArm.add(RightArmMove); | ||
| 85 | RightArm.add(RightArmOn); | ||
| 86 | RightArm.add(RightArmOff); | ||
| 87 | |||
| 88 | // La gamba sinistra. | ||
| 89 | LeftLegMove.addActionListener(listener); | ||
| 90 | LeftLegMove.setActionCommand("leftlegmove"); | ||
| 91 | |||
| 92 | LeftLegOn.addActionListener(listener); | ||
| 93 | LeftLegOn.setActionCommand("leftlegon"); | ||
| 94 | |||
| 95 | LeftLegOff.addActionListener(listener); | ||
| 96 | LeftLegOff.setActionCommand("leftlegoff"); | ||
| 97 | |||
| 98 | LeftLeg.add(LeftLegMove); | ||
| 99 | LeftLeg.add(LeftLegOn); | ||
| 100 | LeftLeg.add(LeftLegOff); | ||
| 101 | |||
| 102 | // La gamba destra. | ||
| 103 | RightLegMove.addActionListener(listener); | ||
| 104 | RightLegMove.setActionCommand("rightlegmove"); | ||
| 105 | |||
| 106 | RightLegOn.addActionListener(listener); | ||
| 107 | RightLegOn.setActionCommand("rightlegon"); | ||
| 108 | |||
| 109 | RightLegOff.addActionListener(listener); | ||
| 110 | RightLegOff.setActionCommand("rightlegoff"); | ||
| 111 | |||
| 112 | RightLeg.add(RightLegMove); | ||
| 113 | RightLeg.add(RightLegOn); | ||
| 114 | RightLeg.add(RightLegOff); | ||
| 115 | |||
| 116 | // Menu rinomina. | ||
| 117 | Rename.addActionListener(listener); | ||
| 118 | Rename.setActionCommand("rename"); | ||
| 119 | |||
| 120 | Menu modifica = new Menu("Modifica"); | ||
| 121 | modifica.add(LeftArm); | ||
| 122 | modifica.add(RightArm); | ||
| 123 | modifica.add(LeftLeg); | ||
| 124 | modifica.add(RightLeg); | ||
| 125 | modifica.addSeparator(); | ||
| 126 | modifica.add(Rename); | ||
| 127 | |||
| 128 | barraMenu.add(modifica); | ||
| 129 | |||
| 130 | // Menu azioni. | ||
| 131 | Exploud.addActionListener(listener); | ||
| 132 | Exploud.setActionCommand("exploud"); | ||
| 133 | |||
| 134 | Bier.addActionListener(listener); | ||
| 135 | Bier.setActionCommand("bier"); | ||
| 136 | |||
| 137 | xxx.addActionListener(listener); | ||
| 138 | xxx.setActionCommand("xxx"); | ||
| 139 | |||
| 140 | Dance.addActionListener(listener); | ||
| 141 | Dance.setActionCommand("dance"); | ||
| 142 | |||
| 143 | azioni.add(Exploud); | ||
| 144 | azioni.add(Bier); | ||
| 145 | azioni.add(xxx); | ||
| 146 | azioni.add(Dance); | ||
| 147 | |||
| 148 | barraMenu.add(azioni); | ||
| 149 | |||
| 150 | // Menu info. | ||
| 151 | Porky.addActionListener(listener); | ||
| 152 | Porky.setActionCommand("porky"); | ||
| 153 | |||
| 154 | l.addActionListener(listener); | ||
| 155 | l.setActionCommand("l"); | ||
| 156 | |||
| 157 | RobotList.addActionListener(listener); | ||
| 158 | RobotList.setActionCommand("robotlist"); | ||
| 159 | |||
| 160 | info.add(Porky); | ||
| 161 | info.add(l); | ||
| 162 | info.add(RobotList); | ||
| 163 | |||
| 164 | barraMenu.add(info); | ||
| 165 | } | ||
| 166 | |||
| 167 | // Le variabili pubbliche di classe per il metodo "setBounds". | ||
| 168 | public int orizzontale = 0; | ||
| 169 | public int verticale = 0; | ||
| 170 | public int larghezza = 500; | ||
| 171 | public int altezza = 500; | ||
| 172 | |||
| 173 | // E i vari Menu e MenuItem. | ||
| 174 | MenuBar barraMenu = new MenuBar(); | ||
| 175 | Menu file = new Menu("File"); | ||
| 176 | MenuItem NewRobot = new MenuItem("Nuovo robot"); | ||
| 177 | MenuItem ChangeRobot = new MenuItem("Dai i comandi a un altro robot"); | ||
| 178 | MenuItem DeleteRobot = new MenuItem("Elimina un robot"); | ||
| 179 | MenuItem Exit = new MenuItem("Esci"); | ||
| 180 | Menu LeftArm = new Menu("Braccio sinistro"); | ||
| 181 | MenuItem LeftArmMove = new MenuItem("Cambia posizione"); | ||
| 182 | MenuItem LeftArmOn = new MenuItem("Alza"); | ||
| 183 | MenuItem LeftArmOff = new MenuItem("Abbassa"); | ||
| 184 | Menu RightArm = new Menu("Braccio destro"); | ||
| 185 | MenuItem RightArmMove = new MenuItem("Cambia posizione"); | ||
| 186 | MenuItem RightArmOn = new MenuItem("Alza"); | ||
| 187 | MenuItem RightArmOff = new MenuItem("Abbassa"); | ||
| 188 | Menu LeftLeg = new Menu("Gamba sinistra"); | ||
| 189 | MenuItem LeftLegMove = new MenuItem("Cambia posizione"); | ||
| 190 | MenuItem LeftLegOn = new MenuItem("Alza"); | ||
| 191 | MenuItem LeftLegOff = new MenuItem("Abbassa"); | ||
| 192 | Menu RightLeg = new Menu("Gamba destra"); | ||
| 193 | MenuItem RightLegMove = new MenuItem("Cambia posizione"); | ||
| 194 | MenuItem RightLegOn = new MenuItem("Alza"); | ||
| 195 | MenuItem RightLegOff = new MenuItem("Abbassa"); | ||
| 196 | MenuItem Rename = new MenuItem("Rinomina"); | ||
| 197 | Menu azioni = new Menu("Azioni"); | ||
| 198 | MenuItem Exploud = new MenuItem("Esplodi"); | ||
| 199 | MenuItem Bier = new MenuItem("Birra"); | ||
| 200 | MenuItem xxx = new MenuItem("xxx"); | ||
| 201 | MenuItem Dance = new MenuItem("Balla"); | ||
| 202 | Menu info = new Menu("?"); | ||
| 203 | MenuItem Porky = new MenuItem("Informazioni sul programmatore"); | ||
| 204 | MenuItem l = new MenuItem("Legenda Comandi"); | ||
| 205 | MenuItem RobotList = new MenuItem("Lista robot"); | ||
| 206 | } | ||
| 207 | |||
| 208 | |||
| 209 | |||
| 210 | |||
diff --git a/robottino/all_versions/v2.3/src/RobottinoUtils/Listener.java b/robottino/all_versions/v2.3/src/RobottinoUtils/Listener.java new file mode 100755 index 0000000..90e617c --- /dev/null +++ b/robottino/all_versions/v2.3/src/RobottinoUtils/Listener.java | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | // Questa classe è il listener per gli eventi relativi alle finestre. | ||
| 2 | // Dichiaro che farà parte del package RobottinoUtils | ||
| 3 | package RobottinoUtils; | ||
| 4 | |||
| 5 | // Importo i package necessari. | ||
| 6 | import java.awt.event.*; | ||
| 7 | import RobottinoMain.*; | ||
| 8 | import RobottinoAzioni.*; | ||
| 9 | |||
| 10 | public class Listener implements WindowListener, ActionListener { | ||
| 11 | |||
| 12 | RobottinoAzioni robottinoazioni = new RobottinoAzioni(); | ||
| 13 | |||
| 14 | // Ridefinisco i metodi dell'interfaccia WindowListener: | ||
| 15 | // Metodo invocato quando la finestra è stata chiusa: | ||
| 16 | public void windowClosed (WindowEvent evt) { | ||
| 17 | |||
| 18 | // Invoco il metodo sleep(int millisecondi) per mettere il programma in uno stato di attesa | ||
| 19 | // di durata pari ai millisecondi indicati come argomento. | ||
| 20 | System.out.println("La finestra è stata chiusa, il programma terminarà fra 3 secondi"); | ||
| 21 | try { | ||
| 22 | Robottino.threadMain.sleep(1000); | ||
| 23 | } catch (Exception e) { e.printStackTrace(); } | ||
| 24 | System.out.println("2"); | ||
| 25 | try { | ||
| 26 | Robottino.threadMain.sleep(1000); | ||
| 27 | } catch (Exception e) { e.printStackTrace(); } | ||
| 28 | System.out.println("1"); | ||
| 29 | try { | ||
| 30 | Robottino.threadMain.sleep(1000); | ||
| 31 | } catch (Exception e) { e.printStackTrace(); } | ||
| 32 | System.out.println("Programma terminato"); | ||
| 33 | System.exit(0); | ||
| 34 | } | ||
| 35 | |||
| 36 | // Metodo invocato quando la finestra è in fase di chiusura: | ||
| 37 | public void windowClosing (WindowEvent evt) { | ||
| 38 | System.out.println ("Chiusura finestra in corso"); | ||
| 39 | evt.getWindow().dispose(); | ||
| 40 | } | ||
| 41 | |||
| 42 | // Metodo invocato quando una finestra viene ridotta a icona: | ||
| 43 | public void windowIconified (WindowEvent evt) { | ||
| 44 | System.out.println("La finestra è stata ridotta a icona"); | ||
| 45 | } | ||
| 46 | |||
| 47 | // Metodo invocato quando una finestra ridotta a icona viene ingrandita: | ||
| 48 | public void windowDeiconified (WindowEvent evt) { | ||
| 49 | System.out.println("La finestra ridotta a icona è stata ingrandita"); | ||
| 50 | } | ||
| 51 | |||
| 52 | // Metodo invocato quando una finestra viene aperta: | ||
| 53 | public void windowOpened (WindowEvent evt) {} | ||
| 54 | |||
| 55 | // Metodo invocato quando una finestra diventa attiva: | ||
| 56 | public void windowActivated (WindowEvent evt) {} | ||
| 57 | |||
| 58 | // Metodo invocato quando una finestra viene disattivata: | ||
| 59 | public void windowDeactivated (WindowEvent evt) {} | ||
| 60 | |||
| 61 | // Metodo invocato quando viene utilizzata la barra del menu: | ||
| 62 | // descrive tutte le azioni da compiere per ogni evento ricevuto | ||
| 63 | // dal menu. | ||
| 64 | public void actionPerformed (ActionEvent e) { | ||
| 65 | System.out.println (robottinoazioni.Azioni(e.getActionCommand(), RobottinoAzioni.nomeRobot, RobottinoAzioni.pdrA)); | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
diff --git a/robottino/all_versions/v2.3/src/RobottinoUtils/PartiDelRobot.java b/robottino/all_versions/v2.3/src/RobottinoUtils/PartiDelRobot.java new file mode 100755 index 0000000..d6cf869 --- /dev/null +++ b/robottino/all_versions/v2.3/src/RobottinoUtils/PartiDelRobot.java | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. | ||
| 2 | package RobottinoUtils; | ||
| 3 | |||
| 4 | // Dichiaro la classe. | ||
| 5 | public class PartiDelRobot { | ||
| 6 | |||
| 7 | // Creo un costruttore senza argomenti. | ||
| 8 | // Se non lo facessi sarei obbligato a passare gli argomenti | ||
| 9 | // del secondo costruttore ogni volta che voglio istanziare la classe. | ||
| 10 | public PartiDelRobot() {} | ||
| 11 | |||
| 12 | // Il secondo costruttore riceve come argomenti un booleano che passerà il valore a "statoParte" | ||
| 13 | // e una stringa che passa il valore a "stringaParte". | ||
| 14 | public PartiDelRobot(boolean b, String s) { | ||
| 15 | this.stringaParte = s; | ||
| 16 | this.statoParte = b; | ||
| 17 | } | ||
| 18 | |||
| 19 | // Infine le due variabili pubbliche della classe. | ||
| 20 | public String stringaParte; | ||
| 21 | public boolean statoParte; | ||
| 22 | } | ||
diff --git a/robottino/all_versions/v3.0/Esegui.bat b/robottino/all_versions/v3.0/Esegui.bat new file mode 100755 index 0000000..d413ed8 --- /dev/null +++ b/robottino/all_versions/v3.0/Esegui.bat | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | cd ./bin | ||
| 2 | java RobottinoMain/Robottino | ||
| 3 | cd | ||
diff --git a/robottino/all_versions/v3.0/Esegui.sh b/robottino/all_versions/v3.0/Esegui.sh new file mode 100755 index 0000000..d413ed8 --- /dev/null +++ b/robottino/all_versions/v3.0/Esegui.sh | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | cd ./bin | ||
| 2 | java RobottinoMain/Robottino | ||
| 3 | cd | ||
diff --git a/robottino/all_versions/v3.0/Readme.txt b/robottino/all_versions/v3.0/Readme.txt new file mode 100755 index 0000000..52d532c --- /dev/null +++ b/robottino/all_versions/v3.0/Readme.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | Il programma necessita della JVM (Java Virtual Machine) per funzionare correttamente | ||
| 2 | |||
| 3 | Se si usano sistemi Windows aprire il file Esegui.bat | ||
| 4 | Se si usano sistemi Unix dare i permessi necessari ed eseguire il file Esegui.sh | ||
| 5 | Se si usano altri sistemi aprire una shell e digitare i comandi | ||
| 6 | |||
| 7 | cd <percorsoFile>/bin | ||
| 8 | java Robottino | ||
| 9 | |||
| 10 | dove percorsoFile è il percorso di questo file. | ||
diff --git a/robottino/all_versions/v3.0/bin/Immagini/ImmagineRobot.class b/robottino/all_versions/v3.0/bin/Immagini/ImmagineRobot.class new file mode 100755 index 0000000..6089c8a --- /dev/null +++ b/robottino/all_versions/v3.0/bin/Immagini/ImmagineRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/Immagini/img/laoff.gif b/robottino/all_versions/v3.0/bin/Immagini/img/laoff.gif new file mode 100755 index 0000000..49d9db0 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/Immagini/img/laoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/Immagini/img/lloff.gif b/robottino/all_versions/v3.0/bin/Immagini/img/lloff.gif new file mode 100755 index 0000000..3db1ceb --- /dev/null +++ b/robottino/all_versions/v3.0/bin/Immagini/img/lloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/Immagini/img/raoff.gif b/robottino/all_versions/v3.0/bin/Immagini/img/raoff.gif new file mode 100755 index 0000000..88aabc4 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/Immagini/img/raoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/Immagini/img/rloff.gif b/robottino/all_versions/v3.0/bin/Immagini/img/rloff.gif new file mode 100755 index 0000000..04bda22 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/Immagini/img/rloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/Immagini/img/robot.gif b/robottino/all_versions/v3.0/bin/Immagini/img/robot.gif new file mode 100755 index 0000000..db87686 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/Immagini/img/robot.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/RobottinoAzioni/RobottinoAzioni.class b/robottino/all_versions/v3.0/bin/RobottinoAzioni/RobottinoAzioni.class new file mode 100755 index 0000000..d8aeb55 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/RobottinoAzioni/RobottinoAzioni.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/RobottinoMain/Robottino.class b/robottino/all_versions/v3.0/bin/RobottinoMain/Robottino.class new file mode 100755 index 0000000..2a1b0e3 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/RobottinoMain/Robottino.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/RobottinoUtils/Grafica.class b/robottino/all_versions/v3.0/bin/RobottinoUtils/Grafica.class new file mode 100755 index 0000000..80ef9bc --- /dev/null +++ b/robottino/all_versions/v3.0/bin/RobottinoUtils/Grafica.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/RobottinoUtils/Listener.class b/robottino/all_versions/v3.0/bin/RobottinoUtils/Listener.class new file mode 100755 index 0000000..e198976 --- /dev/null +++ b/robottino/all_versions/v3.0/bin/RobottinoUtils/Listener.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/bin/RobottinoUtils/PartiDelRobot.class b/robottino/all_versions/v3.0/bin/RobottinoUtils/PartiDelRobot.class new file mode 100755 index 0000000..fcc8e9e --- /dev/null +++ b/robottino/all_versions/v3.0/bin/RobottinoUtils/PartiDelRobot.class | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/src/Immagini/ImmagineRobot.java b/robottino/all_versions/v3.0/src/Immagini/ImmagineRobot.java new file mode 100755 index 0000000..ee0bc1f --- /dev/null +++ b/robottino/all_versions/v3.0/src/Immagini/ImmagineRobot.java | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | package Immagini; | ||
| 2 | import java.awt.*; | ||
| 3 | import java.awt.image.*; | ||
| 4 | |||
| 5 | public class ImmagineRobot { | ||
| 6 | |||
| 7 | public Toolkit t; | ||
| 8 | public Image robot; | ||
| 9 | public Image raon; | ||
| 10 | public Image raoff; | ||
| 11 | public Image laon; | ||
| 12 | public Image laoff; | ||
| 13 | public Image rlon; | ||
| 14 | public Image rloff; | ||
| 15 | public Image llon; | ||
| 16 | public Image lloff; | ||
| 17 | public Image birra; | ||
| 18 | |||
| 19 | public ImmagineRobot() { | ||
| 20 | |||
| 21 | t = Toolkit.getDefaultToolkit(); | ||
| 22 | robot = t.getImage("./Immagini/img/robot.gif"); | ||
| 23 | raon = t.getImage("./Immagini/img/raon.gif"); | ||
| 24 | raoff = t.getImage("./Immagini/img/raoff.gif"); | ||
| 25 | laon = t.getImage("./Immagini/img/laon.gif"); | ||
| 26 | laoff = t.getImage("./Immagini/img/laoff.gif"); | ||
| 27 | rlon = t.getImage("./Immagini/img/rlon.gif"); | ||
| 28 | rloff = t.getImage("./Immagini/img/rloff.gif"); | ||
| 29 | llon = t.getImage("./Immagini/img/llon.gif"); | ||
| 30 | lloff = t.getImage("./Immagini/img/lloff.gif"); | ||
| 31 | birra = t.getImage("./Immagini/img/birra.gif"); | ||
| 32 | |||
| 33 | } | ||
| 34 | |||
| 35 | } | ||
diff --git a/robottino/all_versions/v3.0/src/Immagini/img/laoff.gif b/robottino/all_versions/v3.0/src/Immagini/img/laoff.gif new file mode 100755 index 0000000..49d9db0 --- /dev/null +++ b/robottino/all_versions/v3.0/src/Immagini/img/laoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/src/Immagini/img/lloff.gif b/robottino/all_versions/v3.0/src/Immagini/img/lloff.gif new file mode 100755 index 0000000..3db1ceb --- /dev/null +++ b/robottino/all_versions/v3.0/src/Immagini/img/lloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/src/Immagini/img/raoff.gif b/robottino/all_versions/v3.0/src/Immagini/img/raoff.gif new file mode 100755 index 0000000..88aabc4 --- /dev/null +++ b/robottino/all_versions/v3.0/src/Immagini/img/raoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/src/Immagini/img/rloff.gif b/robottino/all_versions/v3.0/src/Immagini/img/rloff.gif new file mode 100755 index 0000000..04bda22 --- /dev/null +++ b/robottino/all_versions/v3.0/src/Immagini/img/rloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/src/Immagini/img/robot.gif b/robottino/all_versions/v3.0/src/Immagini/img/robot.gif new file mode 100755 index 0000000..db87686 --- /dev/null +++ b/robottino/all_versions/v3.0/src/Immagini/img/robot.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v3.0/src/RobottinoAzioni/RobottinoAzioni.java b/robottino/all_versions/v3.0/src/RobottinoAzioni/RobottinoAzioni.java new file mode 100755 index 0000000..27d568a --- /dev/null +++ b/robottino/all_versions/v3.0/src/RobottinoAzioni/RobottinoAzioni.java | |||
| @@ -0,0 +1,397 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoAzioni, che verrà poi importato dalle classi Listener e Grafica. | ||
| 2 | package RobottinoAzioni; | ||
| 3 | |||
| 4 | // Anche qui impoerto i package necessari. | ||
| 5 | // java.util.Scanner gestisce gli input da tastiera | ||
| 6 | import java.util.Scanner; | ||
| 7 | |||
| 8 | // java.util.Vector | ||
| 9 | import java.util.Vector; | ||
| 10 | |||
| 11 | // Package definito da me. | ||
| 12 | import RobottinoUtils.*; | ||
| 13 | |||
| 14 | public class RobottinoAzioni { | ||
| 15 | |||
| 16 | // Creo gli oggetti statici che riempiranno il vettore pdrA: | ||
| 17 | // pdrA è un vettore multidimensionale che a sua volta contiene vettori | ||
| 18 | // (il primo si chiama pdrB, i successivi non avranno nome) che coontengono | ||
| 19 | // 4 istanze di PartiDelRobot, cioè i 4 arti del robot. | ||
| 20 | // Poi creo un vettore che conterrà i nomi dei robot. | ||
| 21 | // Creo il vettore principale... | ||
| 22 | public static Vector pdrA = new Vector(1); | ||
| 23 | |||
| 24 | // ...e il "sottovettore" come istanze della classe Vector | ||
| 25 | public static Vector pdrB = new Vector(4); | ||
| 26 | |||
| 27 | // Creo le quattro istanze di PartidelRobot utilizzando l'apposito costruttore | ||
| 28 | // passo a tutte una stringa e un valore boleano che determina lo stato | ||
| 29 | // (alzato/a se true, abbassato/a se false). | ||
| 30 | public static PartiDelRobot leftArm = new PartiDelRobot(false, "il braccio sinistro alzato"); | ||
| 31 | public static PartiDelRobot rightArm = new PartiDelRobot(false, "il braccio destro alzato"); | ||
| 32 | public static PartiDelRobot leftLeg = new PartiDelRobot(false, "la gamba sinistra alzata"); | ||
| 33 | public static PartiDelRobot rightLeg = new PartiDelRobot(false, "la gamba destra alzata"); | ||
| 34 | |||
| 35 | // Il vettore nomeRobot per i nomi | ||
| 36 | // il vettore può contenere stringhe, poichè non sono tipi primitivi ma oggetti della classe String | ||
| 37 | public static Vector nomeRobot = new Vector(1); | ||
| 38 | |||
| 39 | // La variabile robotIndex serve a tenere in memoria su quale robot si sta operando: | ||
| 40 | // in seguito verrà usata quando l'utente deciderà di creare più di un robot | ||
| 41 | // e poi di dare comandi a uno o all'altro/i. | ||
| 42 | int robotIndex = 0; | ||
| 43 | |||
| 44 | // Dichiarazione del metodo Azioni. | ||
| 45 | public String Azioni(String comando, Vector nomeRobot, Vector pdrA) { | ||
| 46 | |||
| 47 | // Crea un'istanza della classe Scanner per | ||
| 48 | // ricevere gli input nel caso in cui debba essere dato il nome | ||
| 49 | // al robottino o scelto un robottino da una lista. | ||
| 50 | Scanner sc2 = new Scanner(System.in); | ||
| 51 | |||
| 52 | // La variabile contatore memorizza il numero di variabili "PartiDelRobot.statoParte" | ||
| 53 | // che hanno valore true, ossia il numero di arti alzati di un robottino | ||
| 54 | // in modo da poter scegliere la frase giusta da dare come output | ||
| 55 | // al posto dell'immagine del robottino con tali arti alzati. | ||
| 56 | int contatore = 0; | ||
| 57 | |||
| 58 | // Questo array ha il compito di memorizzare le stringhe corrispondenti agli alzati | ||
| 59 | // per motivi simili a quelli della variabile "contatore". | ||
| 60 | String stat[] = {"", "", "", ""}; | ||
| 61 | |||
| 62 | // La stringa Return verrà successivamente modificata e restituita in alcuni casi. | ||
| 63 | String Return = "Errore - si consiglia di picchiare il programmatore"; | ||
| 64 | |||
| 65 | // Per far si che il programma non distingua tra lettere maiuscole o minuscole per quanto riguardo gli input | ||
| 66 | // è stato usato il metodo "equalsIgnoreCase" della classe String. | ||
| 67 | // I quattro casi successivi cambiano il valore della varibalie "statoParte" relativa all'arto | ||
| 68 | // Che deve mouversi (quindi cambiare la sua posizione). | ||
| 69 | if (comando.equalsIgnoreCase("leftarmmove")) | ||
| 70 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = | ||
| 71 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte; | ||
| 72 | |||
| 73 | else if (comando.equalsIgnoreCase("rightarmmove")) | ||
| 74 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = | ||
| 75 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte; | ||
| 76 | |||
| 77 | else if (comando.equalsIgnoreCase("leftlegmove")) | ||
| 78 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = | ||
| 79 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte; | ||
| 80 | |||
| 81 | else if (comando.equalsIgnoreCase("rightlegmove")) | ||
| 82 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = | ||
| 83 | !((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte; | ||
| 84 | |||
| 85 | // I casi successivi modificano il valore della varibile analogamente ai 4 precedenti. | ||
| 86 | else if (comando.equalsIgnoreCase("leftarmon")) | ||
| 87 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = true; | ||
| 88 | |||
| 89 | else if (comando.equalsIgnoreCase("rightarmon")) | ||
| 90 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = true; | ||
| 91 | |||
| 92 | else if (comando.equalsIgnoreCase("leftlegon")) | ||
| 93 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = true; | ||
| 94 | |||
| 95 | else if (comando.equalsIgnoreCase("rightlegon")) | ||
| 96 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = true; | ||
| 97 | |||
| 98 | else if (comando.equalsIgnoreCase("leftarmoff")) | ||
| 99 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(0)).statoParte = false; | ||
| 100 | |||
| 101 | else if (comando.equalsIgnoreCase("rightarmoff")) | ||
| 102 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(1)).statoParte = false; | ||
| 103 | |||
| 104 | else if (comando.equalsIgnoreCase("leftlegoff")) | ||
| 105 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(2)).statoParte = false; | ||
| 106 | |||
| 107 | else if (comando.equalsIgnoreCase("rightlegoff")) | ||
| 108 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(3)).statoParte = false; | ||
| 109 | |||
| 110 | // Il caso successi si verica quando il comando è "exploud". | ||
| 111 | else if (comando.equalsIgnoreCase("exploud")) { | ||
| 112 | |||
| 113 | // Scrive sullo schermo la seguente frase, che comprende il nome del robottino che non è ancora stato fatto eliminare | ||
| 114 | System.out.println | ||
| 115 | ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot.elementAt(this.robotIndex) + "! Aspetta che te ne faccio un altro"); | ||
| 116 | System.out.println ("..."); | ||
| 117 | |||
| 118 | // Con un ciclo for rendo false tutte le variabili "statoParte" per far sì che il robottino sia come nuovo. | ||
| 119 | for (int i = 0; i < 4; i++) { | ||
| 120 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 121 | } | ||
| 122 | |||
| 123 | // E azzero anche il nome del robot | ||
| 124 | this.nomeRobot.setElementAt("", this.robotIndex); | ||
| 125 | |||
| 126 | return "Fatto, puoi continuare a giocare"; | ||
| 127 | } | ||
| 128 | |||
| 129 | // Caso per il comando "bier". | ||
| 130 | // La reazione a questo comando è un semplice output quasi totalmente scorrelato al robottino | ||
| 131 | // se non per il fatto che appare il nome del robottino attuale. | ||
| 132 | else if (comando.equalsIgnoreCase("bier")) { | ||
| 133 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "sta trangugiando una birra..."); | ||
| 134 | System.out.println ("Buurrrrrrrrp!"); | ||
| 135 | return "La birra analcolica fa schifo!"; | ||
| 136 | } | ||
| 137 | |||
| 138 | // Per il comando "rename", rinomina. | ||
| 139 | else if (comando.equalsIgnoreCase("rename")) { | ||
| 140 | |||
| 141 | System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot.elementAt(this.robotIndex)); | ||
| 142 | System.out.println ("Digita il nuovo nome e premi INVIO per coninuare"); | ||
| 143 | |||
| 144 | // Cambia il nome del robottino attuale con quello dell'input. | ||
| 145 | this.nomeRobot.setElementAt(sc2.nextLine(), this.robotIndex); | ||
| 146 | |||
| 147 | // Se il nome non è vuoto, aggiunge un carattere di spazio per migliorare la visualizzazione nelle frasi di output. | ||
| 148 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 149 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 150 | |||
| 151 | // Semplice output con il nuovo nome. | ||
| 152 | return "Ora il robottino si chiama " + nomeRobot.elementAt(this.robotIndex); | ||
| 153 | } | ||
| 154 | |||
| 155 | // Per il comando "porky". | ||
| 156 | // Ancora meno che per "bier". | ||
| 157 | else if (comando.equalsIgnoreCase("porky")) { | ||
| 158 | System.out.println ("Porky è un grande"); | ||
| 159 | System.out.println ("Per maggiori informazioni visita il sito"); | ||
| 160 | return "http://kakati.forumfree.net/"; | ||
| 161 | } | ||
| 162 | |||
| 163 | // Il comando "xxx" ha funzioni analoghe a bier. | ||
| 164 | else if (comando.equalsIgnoreCase("xxx")) { | ||
| 165 | System.out.println ("Il robottino " + nomeRobot.elementAt(this.robotIndex) + "ha incontrato una bella robottina..."); | ||
| 166 | return "*Censura*"; | ||
| 167 | } | ||
| 168 | |||
| 169 | // "dance" setta tutte le variabili "statoParte" a false... | ||
| 170 | else if (comando.equalsIgnoreCase("dance")) { | ||
| 171 | |||
| 172 | System.out.println ("Immagini che il robottino " + nomeRobot.elementAt(this.robotIndex) + " stia ballando..."); | ||
| 173 | System.out.println ("Il robottino ha smesso di ballare"); | ||
| 174 | |||
| 175 | //...con questo ciclo for | ||
| 176 | for (int i = 0; i < 4; i++) { | ||
| 177 | ((PartiDelRobot)((Vector)this.pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte = false; | ||
| 178 | } | ||
| 179 | |||
| 180 | return "Il robottino " + nomeRobot.elementAt(this.robotIndex) + "si è fermato ed è tornato nella posizione originale"; | ||
| 181 | |||
| 182 | // Per il comando "newrobot", che crea un nuovo robottino. | ||
| 183 | } | ||
| 184 | else if (comando.equalsIgnoreCase("newrobot")) { | ||
| 185 | |||
| 186 | // Aggiunge un elemento a "pdrA" con il metodo "addElement", della classe Vector. | ||
| 187 | // È stata necessaria la dicitura this. per modificare realmente il vettore. | ||
| 188 | // Se non lo avessi fatto non sarebbe successo, in quanto i metodi operano | ||
| 189 | // su i valori e non sulle variabili/oggetti. | ||
| 190 | this.pdrA.addElement(pdrB); | ||
| 191 | |||
| 192 | // Aggiungo le 4 parti del robot. | ||
| 193 | // Forse avete già notato (ma quì sono più evidenti) alcuni cast che ho fatto: | ||
| 194 | // sono per far si che il compilatore capisca che il metodo viene invocato da un oggetto | ||
| 195 | // della classe vector, che senza cast considererebbe della classe Object. | ||
| 196 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftArm); | ||
| 197 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightArm); | ||
| 198 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (leftLeg); | ||
| 199 | ((Vector)(this.pdrA.elementAt(pdrA.size()-1))).addElement (rightLeg); | ||
| 200 | |||
| 201 | // Semplice output con richiesta di nome per il nuovo robottino. | ||
| 202 | System.out.println ("È stato creato un nuovo robot. Vuoi dare un nome al nuovo robot?"); | ||
| 203 | System.out.println ("Inserisci il nuovo nome e premi INVIO oppure lascia vuoto e premi INVIO"); | ||
| 204 | |||
| 205 | String newName = sc2.nextLine(); | ||
| 206 | |||
| 207 | if (!(((String)nomeRobot.elementAt(this.robotIndex)).equalsIgnoreCase(""))) | ||
| 208 | this.nomeRobot.setElementAt(this.nomeRobot.elementAt(this.robotIndex) + " ", this.robotIndex); | ||
| 209 | |||
| 210 | this.nomeRobot.addElement(newName); | ||
| 211 | |||
| 212 | return "È stato creato il robottino " + newName; | ||
| 213 | } | ||
| 214 | |||
| 215 | // Il comando "deleterobot", per eliminare un robot. | ||
| 216 | else if (comando.equalsIgnoreCase("deleterobot")) { | ||
| 217 | |||
| 218 | // Se c'è più di un robot esegue l'eliminazione. | ||
| 219 | if (pdrA.size()>1) { | ||
| 220 | System.out.println ("Quale robottino vuoi eliminare?"); | ||
| 221 | System.out.println (""); | ||
| 222 | |||
| 223 | // Con un ciclo for scrive i nomi di tutti i robot preceduti da un numero in sequenza. | ||
| 224 | // Il numero è il corrispondente del loro indice di vettore. | ||
| 225 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 226 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 227 | } | ||
| 228 | |||
| 229 | // Dà le istruzioni all'utente affinché capisca come eliminare un robot. | ||
| 230 | System.out.println (""); | ||
| 231 | System.out.println("Scegliere il robottino da eliminare digitando il numero corrispondente e premendo INVIO"); | ||
| 232 | System.out.println("Digitare un qualunque altro numero e premere INVIO per annullare"); | ||
| 233 | |||
| 234 | int num = this.pdrA.size()+1; | ||
| 235 | |||
| 236 | try { | ||
| 237 | |||
| 238 | // Riceve in input il numero e ne assegna il valore alla variabile "num". | ||
| 239 | num = sc2.nextInt(); | ||
| 240 | |||
| 241 | } catch (Exception e) { | ||
| 242 | System.out.println("Puoi inserire solo numeri"); | ||
| 243 | } | ||
| 244 | |||
| 245 | // Elimina gli elementi corrispondenti al robottino (nome e robot) dai | ||
| 246 | // rispettivi vettori con il metodo "removeElementAt" della classe Vector. | ||
| 247 | if (num<this.pdrA.size()) { | ||
| 248 | this.pdrA.removeElementAt(num); | ||
| 249 | this.nomeRobot.removeElementAt(num); | ||
| 250 | return "È stato eliminato il robottino numero " + num; | ||
| 251 | } | ||
| 252 | |||
| 253 | // Se il numero ricevuto in input è superiore all'indice dei robot | ||
| 254 | // non elimina alcun robot. | ||
| 255 | else return "Operazione annullata"; | ||
| 256 | } | ||
| 257 | |||
| 258 | // Se c'è solo un robot non esegue l'eliminazione. | ||
| 259 | else return "Hai solo un robottino, non puoi eliminarlo!"; | ||
| 260 | } | ||
| 261 | |||
| 262 | // Il comando "changerobot" per cambiare il robot a cui dare le istruzioni | ||
| 263 | else if (comando.equalsIgnoreCase("changerobot")) { | ||
| 264 | |||
| 265 | // L'esecuzione è simile a quella per il comando "deleterobot", con la differenza che il robot non viene eliminato | ||
| 266 | // ma viene semplicemente cambiato il valore della variabile "robotIndex". | ||
| 267 | if (pdrA.size()>1) { | ||
| 268 | System.out.println ("A quale robottino vuoi dare i comandi?"); | ||
| 269 | System.out.println (""); | ||
| 270 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 271 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 272 | } | ||
| 273 | System.out.println (""); | ||
| 274 | System.out.println ("Digita il numero corrispondente alla tua scelta e premi INVIO"); | ||
| 275 | |||
| 276 | int newIndex = this.pdrA.size()+1; | ||
| 277 | |||
| 278 | try { | ||
| 279 | |||
| 280 | newIndex = sc2.nextInt(); | ||
| 281 | |||
| 282 | } catch (Exception e) { | ||
| 283 | System.out.println("Puoi inserire solo numeri"); | ||
| 284 | } | ||
| 285 | |||
| 286 | // Prima di cambiare valore alla variabile di indice verifica che il numero sia valido. | ||
| 287 | if (newIndex<this.pdrA.size()) { | ||
| 288 | this.robotIndex = newIndex; | ||
| 289 | return "È stato selezionato il robottino numero " + this.robotIndex + ": " + this.nomeRobot.elementAt | ||
| 290 | (this.robotIndex); | ||
| 291 | } | ||
| 292 | |||
| 293 | // Se non lo è non esegue l'assegnamento. | ||
| 294 | else return "Numero non valido - Operazione annullata"; | ||
| 295 | } | ||
| 296 | else { | ||
| 297 | return "Hai solo un robottino, non puoi cambiarlo con un altro!"; | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | // Il comando "robotlist" visualizza una lista dei robot presenti. | ||
| 302 | else if (comando.equalsIgnoreCase("robotlist")) { | ||
| 303 | for (int i = 0; i<this.pdrA.size(); i++) { | ||
| 304 | System.out.println (i + ". " + this.nomeRobot.elementAt(i)); | ||
| 305 | } | ||
| 306 | return ""; | ||
| 307 | } | ||
| 308 | |||
| 309 | // Il comando "l", per la legenda, visualizza la lista dei comandi con relativa descrizione. | ||
| 310 | else if (comando.equalsIgnoreCase("l")) { | ||
| 311 | System.out.println ("Legenda comandi"); | ||
| 312 | System.out.println (""); | ||
| 313 | System.out.println ("Comandi relativi agli arti"); | ||
| 314 | System.out.println (""); | ||
| 315 | System.out.println ("LeftArmMove: cambia la posizione corrente del braccio sinistro del robot"); | ||
| 316 | System.out.println ("RightArmMove: cambia la posizione corrente del braccio destro del robot"); | ||
| 317 | System.out.println ("LeftLegMove: cambia la posizione corrente della gamba sinistra del robot"); | ||
| 318 | System.out.println ("RightLegMove: cambia la posizione corrente della gamba destra del robot"); | ||
| 319 | System.out.println ("LeftArmOn: se il braccio sinistro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 320 | System.out.println ("RightArmOn: se il braccio destro non è alzato, lo alza, altrimenti la posizione resta invariata"); | ||
| 321 | System.out.println ("LeftLegOn: se la gamba sinistra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 322 | System.out.println ("RightLegOn: se la gamba destra non è alzata, la alza, altrimenti la posizione resta invariata"); | ||
| 323 | System.out.println ("LeftArmOff: se il braccio sinistro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 324 | System.out.println ("RightArmOff: se il braccio destro non è abbassato, lo abbassa, altrimenti la posizione resta invariata"); | ||
| 325 | System.out.println ("LeftLegOff: se la gamba sinistra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 326 | System.out.println ("RightLegOff: se la gamba destra non è abbassata, la abbassa, altrimenti la posizione resta invariata"); | ||
| 327 | System.out.println (""); | ||
| 328 | System.out.println ("Altri comandi:"); | ||
| 329 | System.out.println (""); | ||
| 330 | System.out.println ("NewRobot: aggiunge un nuovo robot"); | ||
| 331 | System.out.println ("ChangeRobot: cambia il robot attuale"); | ||
| 332 | System.out.println ("RobotList: visualizza la lista dei robot"); | ||
| 333 | System.out.println ("Rename: rinomina il robottino"); | ||
| 334 | System.out.println (""); | ||
| 335 | System.out.println ("Comandi a sorpresa:"); | ||
| 336 | System.out.println (""); | ||
| 337 | System.out.println ("Exploud"); | ||
| 338 | System.out.println ("Bier"); | ||
| 339 | System.out.println ("Porky"); | ||
| 340 | System.out.println ("xxx"); | ||
| 341 | System.out.println ("dance"); | ||
| 342 | System.out.println (""); | ||
| 343 | System.out.println ("Exit: esci dal programma"); | ||
| 344 | |||
| 345 | return ""; | ||
| 346 | |||
| 347 | } | ||
| 348 | |||
| 349 | // Se il comando è exit, esce dal programma. | ||
| 350 | else if (comando.equalsIgnoreCase("exit")) { | ||
| 351 | System.exit(0); | ||
| 352 | return ""; | ||
| 353 | } | ||
| 354 | |||
| 355 | // Se l'input non è tra i comandi prestabiliti, visualizza la seguente scritta sullo schermo. | ||
| 356 | else | ||
| 357 | System.out.println ("Comando non riconosciuto - digitare l per una legenda dei comandi disponibili"); | ||
| 358 | System.out.println (""); | ||
| 359 | |||
| 360 | // Quì di seguito viene chiarito l'utilizzo di "contatore" e "sta[]". | ||
| 361 | // Per ogni varibile "statoParte" che ha valore true, contatore viene incrementato | ||
| 362 | // e l'elemento successivo dell'array "stat[]" assume il valore della stringa corrispondente. | ||
| 363 | for (int i = 0, j = 0; i < 4; i++) { | ||
| 364 | if (((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).statoParte) { | ||
| 365 | contatore += 1; | ||
| 366 | stat[j++] = ((PartiDelRobot)((Vector)pdrA.elementAt(this.robotIndex)).elementAt(i)).stringaParte; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | // La restituzione finale delle frasi, con uno switch che a seconda del valore di contatore | ||
| 371 | // restituisce una frase o l'altra. | ||
| 372 | switch (contatore) { | ||
| 373 | case 0: | ||
| 374 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"non ha nessun arto alzato"; | ||
| 375 | break; | ||
| 376 | case 1: | ||
| 377 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0] + "."; | ||
| 378 | break; | ||
| 379 | case 2: | ||
| 380 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0]+" e "+stat[1]+"."; | ||
| 381 | break; | ||
| 382 | case 3: | ||
| 383 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0]+", "+stat[1]+" e "+stat[2]+"."; | ||
| 384 | break; | ||
| 385 | case 4: | ||
| 386 | Return = "Il robottino "+nomeRobot.elementAt(this.robotIndex)+"ha "+stat[0]+", "+stat[1]+", "+stat[2]+" e "+stat[3]+". Sta per cadere! Ah no, può restare sospeso in aria"; | ||
| 387 | break; | ||
| 388 | } | ||
| 389 | return Return; | ||
| 390 | } | ||
| 391 | //Fine del metodo Azioni | ||
| 392 | } | ||
| 393 | |||
| 394 | |||
| 395 | |||
| 396 | |||
| 397 | |||
diff --git a/robottino/all_versions/v3.0/src/RobottinoMain/Robottino.java b/robottino/all_versions/v3.0/src/RobottinoMain/Robottino.java new file mode 100755 index 0000000..5b9c530 --- /dev/null +++ b/robottino/all_versions/v3.0/src/RobottinoMain/Robottino.java | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | // Robottino versione 3.0 | ||
| 2 | |||
| 3 | // Dichiaro che questa classe fa parte del package RobottinoMain, che verrà poi importato | ||
| 4 | // dalle classi che dovranno interagire con essa. | ||
| 5 | package RobottinoMain; | ||
| 6 | |||
| 7 | // Importo la classe Grafica per poter "costruire" una finestra. | ||
| 8 | import RobottinoUtils.*; | ||
| 9 | |||
| 10 | // E il package Robottinoazioni per poterne inizializzare i vettori | ||
| 11 | import RobottinoAzioni.*; | ||
| 12 | |||
| 13 | // java.util.Vector serve a gestire i vettori. | ||
| 14 | // I vettori sono come array, ma hanno due differenze principali: | ||
| 15 | // 1) la loro lunghezza può variare durante l'esecuzione del programma | ||
| 16 | // (per questo li ho preferiti agli array); | ||
| 17 | // 2) possono contenere soltanto oggetti, e non tipi primitivi. | ||
| 18 | import java.util.Vector; | ||
| 19 | |||
| 20 | // Dichiaro la classe. | ||
| 21 | public class Robottino { | ||
| 22 | |||
| 23 | // Istanzio la classe Thread per poter utilizzare il metodo sleep(int millisecondi) | ||
| 24 | // che in un metodo dell'interfaccia WindowListener, overridato nella classe Listener | ||
| 25 | // servirà a mettere il programma in uno stato di pausa. | ||
| 26 | // Sarebbe comunque possibile invocarlo, ma così sarà più facile da modificare in futuro. | ||
| 27 | public Thread threadMain; | ||
| 28 | |||
| 29 | // Crea la finestra tramite un'istanza della classe Grafica, del package RobottinoUtils. | ||
| 30 | public Grafica finestra; | ||
| 31 | |||
| 32 | // Creo anche un'istanza di questa classe per avere accesso agli elementi non statici. | ||
| 33 | public static Robottino robottino; | ||
| 34 | |||
| 35 | // Inizio del metodo main... | ||
| 36 | public static void main(String[] args) { | ||
| 37 | |||
| 38 | // Inizializzo i vari oggetti. | ||
| 39 | robottino = new Robottino(); | ||
| 40 | robottino.finestra = new Grafica(); | ||
| 41 | robottino.threadMain = new Thread(Thread.currentThread()); | ||
| 42 | |||
| 43 | // Aggiungo gli elementi ai vettori. | ||
| 44 | // non potevo farlo prima, poiché al di fuori di un metodo è possibile soltanto | ||
| 45 | // dichiarare oggetti/variabili (e inizializzarli) o dichiarare un metodo | ||
| 46 | // e in RobottinoAzioni è presente solo il metodo Azioni che viene richiamato più volte. | ||
| 47 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.leftArm); | ||
| 48 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.rightArm); | ||
| 49 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.leftLeg); | ||
| 50 | RobottinoAzioni.pdrB.addElement(RobottinoAzioni.rightLeg); | ||
| 51 | RobottinoAzioni.pdrA.addElement(RobottinoAzioni.pdrB); | ||
| 52 | RobottinoAzioni.nomeRobot.addElement(""); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | |||
| 63 | |||
diff --git a/robottino/all_versions/v3.0/src/RobottinoUtils/Grafica.java b/robottino/all_versions/v3.0/src/RobottinoUtils/Grafica.java new file mode 100755 index 0000000..84bc8c0 --- /dev/null +++ b/robottino/all_versions/v3.0/src/RobottinoUtils/Grafica.java | |||
| @@ -0,0 +1,226 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. | ||
| 2 | package RobottinoUtils; | ||
| 3 | |||
| 4 | // Importo i package standard relativi al funzionamento delle finestre e della grafica in generale. | ||
| 5 | import java.awt.*; | ||
| 6 | |||
| 7 | // E i package RobottinoAzioni, RobottinoUtils e Immagini da me definiti. | ||
| 8 | import RobottinoAzioni.*; | ||
| 9 | import RobottinoUtils.Listener; | ||
| 10 | import Immagini.*; | ||
| 11 | |||
| 12 | // La classe è una sottoclasse di Frame per poter sfruttare gli effetti grafici | ||
| 13 | // ma implementa anche l'interfaccia WindowListener, necessaria per gestire gli eventi collegati alle finestre | ||
| 14 | // (riduzione a icona, chiusura...); per questo devo successivamente ridefinire tutti i | ||
| 15 | // metodi dell'interfaccia. | ||
| 16 | public class Grafica extends Frame { | ||
| 17 | |||
| 18 | // Creo un'istanza della classe Listener che userò come listener per gli eventi. | ||
| 19 | public static Listener listener; | ||
| 20 | |||
| 21 | // E una di ImmagineRobot per le immagini. | ||
| 22 | public static ImmagineRobot immagineRobot = new ImmagineRobot(); | ||
| 23 | |||
| 24 | // Il costruttore senza argomenti. | ||
| 25 | public Grafica () { | ||
| 26 | |||
| 27 | // Il metodo "setBounds" posiziona e dimensiona la finestra. | ||
| 28 | setBounds (this.orizzontale, this.verticale, this.larghezza, this.altezza); | ||
| 29 | |||
| 30 | // "setTitle" per il titolo della finestra. | ||
| 31 | setTitle ("Robottino v2.2"); | ||
| 32 | |||
| 33 | // "setVisible" per poterla visualizzare. | ||
| 34 | setVisible (true); | ||
| 35 | |||
| 36 | // E addWindowListener per l'ascoltatore (listener). | ||
| 37 | listener = new Listener(); | ||
| 38 | addWindowListener (listener); | ||
| 39 | |||
| 40 | // Aggiungo la barra del menu con i vari sottomenu | ||
| 41 | setMenuBar (barraMenu); | ||
| 42 | |||
| 43 | // Il menu file. | ||
| 44 | NewRobot.addActionListener(listener); | ||
| 45 | NewRobot.setActionCommand("newrobot"); | ||
| 46 | |||
| 47 | ChangeRobot.addActionListener(listener); | ||
| 48 | ChangeRobot.setActionCommand("changerobot"); | ||
| 49 | |||
| 50 | DeleteRobot.addActionListener(listener); | ||
| 51 | DeleteRobot.setActionCommand("deleterobot"); | ||
| 52 | |||
| 53 | Exit.addActionListener(listener); | ||
| 54 | Exit.setActionCommand("exit"); | ||
| 55 | |||
| 56 | file.add(NewRobot); | ||
| 57 | file.add(ChangeRobot); | ||
| 58 | file.add(DeleteRobot); | ||
| 59 | file.addSeparator(); | ||
| 60 | file.add(Exit); | ||
| 61 | |||
| 62 | barraMenu.add(file); | ||
| 63 | |||
| 64 | // Il braccio sinistro. | ||
| 65 | LeftArmMove.addActionListener(listener); | ||
| 66 | LeftArmMove.setActionCommand("leftarmmove"); | ||
| 67 | |||
| 68 | LeftArmOn.addActionListener(listener); | ||
| 69 | LeftArmOn.setActionCommand("leftarmon"); | ||
| 70 | |||
| 71 | LeftArmOff.addActionListener(listener); | ||
| 72 | LeftArmOff.setActionCommand("leftarmoff"); | ||
| 73 | |||
| 74 | LeftArm.add(LeftArmMove); | ||
| 75 | LeftArm.add(LeftArmOn); | ||
| 76 | LeftArm.add(LeftArmOff); | ||
| 77 | |||
| 78 | // Il braccio destro. | ||
| 79 | RightArmMove.addActionListener(listener); | ||
| 80 | RightArmMove.setActionCommand("rightarmmove"); | ||
| 81 | |||
| 82 | RightArmOn.addActionListener(listener); | ||
| 83 | RightArmOn.setActionCommand("rightarmon"); | ||
| 84 | |||
| 85 | RightArmOff.addActionListener(listener); | ||
| 86 | RightArmOff.setActionCommand("rightarmoff"); | ||
| 87 | |||
| 88 | RightArm.add(RightArmMove); | ||
| 89 | RightArm.add(RightArmOn); | ||
| 90 | RightArm.add(RightArmOff); | ||
| 91 | |||
| 92 | // La gamba sinistra. | ||
| 93 | LeftLegMove.addActionListener(listener); | ||
| 94 | LeftLegMove.setActionCommand("leftlegmove"); | ||
| 95 | |||
| 96 | LeftLegOn.addActionListener(listener); | ||
| 97 | LeftLegOn.setActionCommand("leftlegon"); | ||
| 98 | |||
| 99 | LeftLegOff.addActionListener(listener); | ||
| 100 | LeftLegOff.setActionCommand("leftlegoff"); | ||
| 101 | |||
| 102 | LeftLeg.add(LeftLegMove); | ||
| 103 | LeftLeg.add(LeftLegOn); | ||
| 104 | LeftLeg.add(LeftLegOff); | ||
| 105 | |||
| 106 | // La gamba destra. | ||
| 107 | RightLegMove.addActionListener(listener); | ||
| 108 | RightLegMove.setActionCommand("rightlegmove"); | ||
| 109 | |||
| 110 | RightLegOn.addActionListener(listener); | ||
| 111 | RightLegOn.setActionCommand("rightlegon"); | ||
| 112 | |||
| 113 | RightLegOff.addActionListener(listener); | ||
| 114 | RightLegOff.setActionCommand("rightlegoff"); | ||
| 115 | |||
| 116 | RightLeg.add(RightLegMove); | ||
| 117 | RightLeg.add(RightLegOn); | ||
| 118 | RightLeg.add(RightLegOff); | ||
| 119 | |||
| 120 | // Menu rinomina. | ||
| 121 | Rename.addActionListener(listener); | ||
| 122 | Rename.setActionCommand("rename"); | ||
| 123 | |||
| 124 | Menu modifica = new Menu("Modifica"); | ||
| 125 | modifica.add(LeftArm); | ||
| 126 | modifica.add(RightArm); | ||
| 127 | modifica.add(LeftLeg); | ||
| 128 | modifica.add(RightLeg); | ||
| 129 | modifica.addSeparator(); | ||
| 130 | modifica.add(Rename); | ||
| 131 | |||
| 132 | barraMenu.add(modifica); | ||
| 133 | |||
| 134 | // Menu azioni. | ||
| 135 | Exploud.addActionListener(listener); | ||
| 136 | Exploud.setActionCommand("exploud"); | ||
| 137 | |||
| 138 | Bier.addActionListener(listener); | ||
| 139 | Bier.setActionCommand("bier"); | ||
| 140 | |||
| 141 | xxx.addActionListener(listener); | ||
| 142 | xxx.setActionCommand("xxx"); | ||
| 143 | |||
| 144 | Dance.addActionListener(listener); | ||
| 145 | Dance.setActionCommand("dance"); | ||
| 146 | |||
| 147 | azioni.add(Exploud); | ||
| 148 | azioni.add(Bier); | ||
| 149 | azioni.add(xxx); | ||
| 150 | azioni.add(Dance); | ||
| 151 | |||
| 152 | barraMenu.add(azioni); | ||
| 153 | |||
| 154 | // Menu info. | ||
| 155 | Porky.addActionListener(listener); | ||
| 156 | Porky.setActionCommand("porky"); | ||
| 157 | |||
| 158 | l.addActionListener(listener); | ||
| 159 | l.setActionCommand("l"); | ||
| 160 | |||
| 161 | RobotList.addActionListener(listener); | ||
| 162 | RobotList.setActionCommand("robotlist"); | ||
| 163 | |||
| 164 | info.add(Porky); | ||
| 165 | info.add(l); | ||
| 166 | info.add(RobotList); | ||
| 167 | |||
| 168 | barraMenu.add(info); | ||
| 169 | } | ||
| 170 | |||
| 171 | // Le variabili pubbliche di classe per il metodo "setBounds". | ||
| 172 | public int orizzontale = 0; | ||
| 173 | public int verticale = 0; | ||
| 174 | public int larghezza = 360; | ||
| 175 | public int altezza = 550; | ||
| 176 | |||
| 177 | // E i vari Menu e MenuItem. | ||
| 178 | MenuBar barraMenu = new MenuBar(); | ||
| 179 | Menu file = new Menu("File"); | ||
| 180 | MenuItem NewRobot = new MenuItem("Nuovo robot"); | ||
| 181 | MenuItem ChangeRobot = new MenuItem("Dai i comandi a un altro robot"); | ||
| 182 | MenuItem DeleteRobot = new MenuItem("Elimina un robot"); | ||
| 183 | MenuItem Exit = new MenuItem("Esci"); | ||
| 184 | Menu LeftArm = new Menu("Braccio sinistro"); | ||
| 185 | MenuItem LeftArmMove = new MenuItem("Cambia posizione"); | ||
| 186 | MenuItem LeftArmOn = new MenuItem("Alza"); | ||
| 187 | MenuItem LeftArmOff = new MenuItem("Abbassa"); | ||
| 188 | Menu RightArm = new Menu("Braccio destro"); | ||
| 189 | MenuItem RightArmMove = new MenuItem("Cambia posizione"); | ||
| 190 | MenuItem RightArmOn = new MenuItem("Alza"); | ||
| 191 | MenuItem RightArmOff = new MenuItem("Abbassa"); | ||
| 192 | Menu LeftLeg = new Menu("Gamba sinistra"); | ||
| 193 | MenuItem LeftLegMove = new MenuItem("Cambia posizione"); | ||
| 194 | MenuItem LeftLegOn = new MenuItem("Alza"); | ||
| 195 | MenuItem LeftLegOff = new MenuItem("Abbassa"); | ||
| 196 | Menu RightLeg = new Menu("Gamba destra"); | ||
| 197 | MenuItem RightLegMove = new MenuItem("Cambia posizione"); | ||
| 198 | MenuItem RightLegOn = new MenuItem("Alza"); | ||
| 199 | MenuItem RightLegOff = new MenuItem("Abbassa"); | ||
| 200 | MenuItem Rename = new MenuItem("Rinomina"); | ||
| 201 | Menu azioni = new Menu("Azioni"); | ||
| 202 | MenuItem Exploud = new MenuItem("Esplodi"); | ||
| 203 | MenuItem Bier = new MenuItem("Birra"); | ||
| 204 | MenuItem xxx = new MenuItem("xxx"); | ||
| 205 | MenuItem Dance = new MenuItem("Balla"); | ||
| 206 | Menu info = new Menu("?"); | ||
| 207 | MenuItem Porky = new MenuItem("Informazioni sul programmatore"); | ||
| 208 | MenuItem l = new MenuItem("Legenda Comandi"); | ||
| 209 | MenuItem RobotList = new MenuItem("Lista robot"); | ||
| 210 | |||
| 211 | |||
| 212 | // Il metodo per disegnare l'immagine del robot. | ||
| 213 | public void paint(Graphics g){ | ||
| 214 | g.drawImage(immagineRobot.robot, 100, 60, this); | ||
| 215 | g.drawImage(immagineRobot.raoff, 66, 248, this); | ||
| 216 | g.drawImage(immagineRobot.laoff, 225, 242, this); | ||
| 217 | g.drawImage(immagineRobot.rloff, 84, 367, this); | ||
| 218 | g.drawImage(immagineRobot.lloff, 148, 367, this); | ||
| 219 | } | ||
| 220 | |||
| 221 | |||
| 222 | } | ||
| 223 | |||
| 224 | |||
| 225 | |||
| 226 | |||
diff --git a/robottino/all_versions/v3.0/src/RobottinoUtils/Listener.java b/robottino/all_versions/v3.0/src/RobottinoUtils/Listener.java new file mode 100755 index 0000000..d9c813a --- /dev/null +++ b/robottino/all_versions/v3.0/src/RobottinoUtils/Listener.java | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | // Questa classe è il listener per gli eventi relativi alle finestre. | ||
| 2 | // Dichiaro che farà parte del package RobottinoUtils | ||
| 3 | package RobottinoUtils; | ||
| 4 | |||
| 5 | // Importo i package necessari. | ||
| 6 | import java.awt.event.*; | ||
| 7 | import RobottinoMain.*; | ||
| 8 | import RobottinoAzioni.*; | ||
| 9 | |||
| 10 | public class Listener implements WindowListener, ActionListener { | ||
| 11 | |||
| 12 | RobottinoAzioni robottinoazioni = new RobottinoAzioni(); | ||
| 13 | |||
| 14 | |||
| 15 | // Ridefinisco i metodi dell'interfaccia WindowListener: | ||
| 16 | // Metodo invocato quando la finestra è stata chiusa: | ||
| 17 | public void windowClosed (WindowEvent evt) { | ||
| 18 | |||
| 19 | // Invoco il metodo sleep(int millisecondi) per mettere il programma in uno stato di attesa | ||
| 20 | // di durata pari ai millisecondi indicati come argomento. | ||
| 21 | System.out.println("La finestra è stata chiusa, il programma terminarà fra 3 secondi"); | ||
| 22 | try { | ||
| 23 | Robottino.robottino.threadMain.sleep(1000); | ||
| 24 | } catch (Exception e) { e.printStackTrace(); } | ||
| 25 | System.out.println("2"); | ||
| 26 | try { | ||
| 27 | Robottino.robottino.threadMain.sleep(1000); | ||
| 28 | } catch (Exception e) { e.printStackTrace(); } | ||
| 29 | System.out.println("1"); | ||
| 30 | try { | ||
| 31 | Robottino.robottino.threadMain.sleep(1000); | ||
| 32 | } catch (Exception e) { e.printStackTrace(); } | ||
| 33 | System.out.println("Programma terminato"); | ||
| 34 | System.exit(0); | ||
| 35 | } | ||
| 36 | |||
| 37 | // Metodo invocato quando la finestra è in fase di chiusura: | ||
| 38 | public void windowClosing (WindowEvent evt) { | ||
| 39 | System.out.println ("Chiusura finestra in corso"); | ||
| 40 | evt.getWindow().dispose(); | ||
| 41 | } | ||
| 42 | |||
| 43 | // Metodo invocato quando una finestra viene ridotta a icona: | ||
| 44 | public void windowIconified (WindowEvent evt) { | ||
| 45 | System.out.println("La finestra è stata ridotta a icona"); | ||
| 46 | } | ||
| 47 | |||
| 48 | // Metodo invocato quando una finestra ridotta a icona viene ingrandita: | ||
| 49 | public void windowDeiconified (WindowEvent evt) { | ||
| 50 | System.out.println("La finestra ridotta a icona è stata ingrandita"); | ||
| 51 | } | ||
| 52 | |||
| 53 | // Metodo invocato quando una finestra viene aperta: | ||
| 54 | public void windowOpened (WindowEvent evt) {} | ||
| 55 | |||
| 56 | // Metodo invocato quando una finestra diventa attiva: | ||
| 57 | public void windowActivated (WindowEvent evt) {} | ||
| 58 | |||
| 59 | // Metodo invocato quando una finestra viene disattivata: | ||
| 60 | public void windowDeactivated (WindowEvent evt) {} | ||
| 61 | |||
| 62 | // Metodo invocato quando viene utilizzata la barra del menu: | ||
| 63 | // descrive tutte le azioni da compiere per ogni evento ricevuto | ||
| 64 | // dal menu. | ||
| 65 | public void actionPerformed (ActionEvent e) { | ||
| 66 | System.out.println (robottinoazioni.Azioni(e.getActionCommand(), RobottinoAzioni.nomeRobot, RobottinoAzioni.pdrA)); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
diff --git a/robottino/all_versions/v3.0/src/RobottinoUtils/PartiDelRobot.java b/robottino/all_versions/v3.0/src/RobottinoUtils/PartiDelRobot.java new file mode 100755 index 0000000..d6cf869 --- /dev/null +++ b/robottino/all_versions/v3.0/src/RobottinoUtils/PartiDelRobot.java | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | // Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. | ||
| 2 | package RobottinoUtils; | ||
| 3 | |||
| 4 | // Dichiaro la classe. | ||
| 5 | public class PartiDelRobot { | ||
| 6 | |||
| 7 | // Creo un costruttore senza argomenti. | ||
| 8 | // Se non lo facessi sarei obbligato a passare gli argomenti | ||
| 9 | // del secondo costruttore ogni volta che voglio istanziare la classe. | ||
| 10 | public PartiDelRobot() {} | ||
| 11 | |||
| 12 | // Il secondo costruttore riceve come argomenti un booleano che passerà il valore a "statoParte" | ||
| 13 | // e una stringa che passa il valore a "stringaParte". | ||
| 14 | public PartiDelRobot(boolean b, String s) { | ||
| 15 | this.stringaParte = s; | ||
| 16 | this.statoParte = b; | ||
| 17 | } | ||
| 18 | |||
| 19 | // Infine le due variabili pubbliche della classe. | ||
| 20 | public String stringaParte; | ||
| 21 | public boolean statoParte; | ||
| 22 | } | ||
diff --git a/robottino/all_versions/v4.0.1/Robottino.jar b/robottino/all_versions/v4.0.1/Robottino.jar new file mode 100755 index 0000000..93b5d53 --- /dev/null +++ b/robottino/all_versions/v4.0.1/Robottino.jar | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/Frame.java b/robottino/all_versions/v4.0.1/src/Frame.java new file mode 100755 index 0000000..8ec087b --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/Frame.java | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | |||
| 25 | public class Frame extends JFrame { | ||
| 26 | public class Listener implements ActionListener { | ||
| 27 | public void actionPerformed( ActionEvent e ) { | ||
| 28 | if ( e.getSource() == exit ) | ||
| 29 | System.exit(0); | ||
| 30 | else if ( e.getSource() == informazioni ) | ||
| 31 | JOptionPane.showMessageDialog( main.frame, "info", "Robottino v4.0 - Informazioni", JOptionPane.INFORMATION_MESSAGE ); | ||
| 32 | else if ( e.getSource() == nuovo ) { | ||
| 33 | String nome = JOptionPane.showInputDialog( main.frame, "Inserire il nome del nuovo robottino:", "Robot " + ( ++main.robots ) ); | ||
| 34 | if ( nome != null ) | ||
| 35 | main.list.newRobot( nome ); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | public static Listener listener; | ||
| 40 | public static Main main; | ||
| 41 | public static JMenuBar barraMenu = new JMenuBar(); | ||
| 42 | public static JMenu file = new JMenu( "File" ); | ||
| 43 | public static JMenu info = new JMenu( "?" ); | ||
| 44 | public static JMenuItem exit = new JMenuItem( "Esci" ); | ||
| 45 | public static JMenuItem informazioni = new JMenuItem( "Informazioni" ); | ||
| 46 | public static JMenuItem nuovo = new JMenuItem( "Nuovo Robot" ); | ||
| 47 | public Frame() { | ||
| 48 | super( "Robottino versione 4.0" ); | ||
| 49 | listener = new Listener(); | ||
| 50 | main = new Main(); | ||
| 51 | exit.addActionListener( listener ); | ||
| 52 | exit.setMnemonic( 'E' ); | ||
| 53 | informazioni.addActionListener( listener ); | ||
| 54 | informazioni.setMnemonic( 'I' ); | ||
| 55 | nuovo.addActionListener( listener ); | ||
| 56 | nuovo.setMnemonic( 'N' ); | ||
| 57 | file.add( exit ); | ||
| 58 | file.add( nuovo ); | ||
| 59 | file.setMnemonic( 'F' ); | ||
| 60 | info.add( informazioni ); | ||
| 61 | info.setMnemonic( '?' ); | ||
| 62 | barraMenu.add( file ); | ||
| 63 | barraMenu.add( info ); | ||
| 64 | setJMenuBar( barraMenu ); | ||
| 65 | } | ||
| 66 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0.1/src/List.java b/robottino/all_versions/v4.0.1/src/List.java new file mode 100755 index 0000000..b4f9982 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/List.java | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JOptionPane; | ||
| 23 | |||
| 24 | public class List { | ||
| 25 | public static Main main = new Main(); | ||
| 26 | public Robot primoRobot, ultimoRobot; | ||
| 27 | public List() { | ||
| 28 | primoRobot = ultimoRobot = null; | ||
| 29 | } | ||
| 30 | public boolean vuota() { | ||
| 31 | return primoRobot == null; | ||
| 32 | } | ||
| 33 | public Robot getRobot( String nome ) { | ||
| 34 | Robot i = primoRobot; | ||
| 35 | for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ; | ||
| 36 | return i; | ||
| 37 | } | ||
| 38 | public void newRobot() { | ||
| 39 | newRobot( false, false, false, false, "" ); | ||
| 40 | } | ||
| 41 | public void newRobot( String nome ) { | ||
| 42 | newRobot( false, false, false, false, nome ); | ||
| 43 | } | ||
| 44 | public void newRobot( boolean la, boolean ra, boolean ll, boolean rl, String nome ) { | ||
| 45 | if ( vuota() ) | ||
| 46 | primoRobot = ultimoRobot = new Robot( la, ra, ll, rl, nome, null, null ); | ||
| 47 | else { | ||
| 48 | ultimoRobot = new Robot( la, ra, ll, rl, nome, ultimoRobot, null ); | ||
| 49 | ultimoRobot.precedenteRobot.prossimoRobot = ultimoRobot; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | public void deleteRobot( String nome ) { | ||
| 53 | if ( vuota() ) | ||
| 54 | JOptionPane.showMessageDialog( main.frame, "Nessun robottino presente. Impossibile cancellarne uno", "Robottino v4.0 - Errore", JOptionPane.ERROR_MESSAGE ); | ||
| 55 | else { | ||
| 56 | Robot i = primoRobot; | ||
| 57 | for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ; | ||
| 58 | if ( i.precedenteRobot != null ) | ||
| 59 | i.precedenteRobot.prossimoRobot = i.prossimoRobot; | ||
| 60 | else | ||
| 61 | primoRobot = i.prossimoRobot; | ||
| 62 | if ( i.prossimoRobot != null ) | ||
| 63 | i.prossimoRobot.precedenteRobot = i.precedenteRobot; | ||
| 64 | else | ||
| 65 | ultimoRobot = i.precedenteRobot; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | public void printList() { | ||
| 69 | String lista = ""; | ||
| 70 | for ( Robot i = primoRobot; i != null; i = i.prossimoRobot ) | ||
| 71 | lista += i.getName() + " "; | ||
| 72 | JOptionPane.showMessageDialog( main.frame, lista, "Robottino v4.0 - Robottini Presenti", JOptionPane.PLAIN_MESSAGE ); | ||
| 73 | } | ||
| 74 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0.1/src/Main.java b/robottino/all_versions/v4.0.1/src/Main.java new file mode 100755 index 0000000..4ef0206 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/Main.java | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JFrame; | ||
| 23 | |||
| 24 | public class Main { | ||
| 25 | public static int robots; | ||
| 26 | public static List list; | ||
| 27 | public static Frame frame; | ||
| 28 | public static void main ( String args[] ) { | ||
| 29 | robots = 0; | ||
| 30 | list = new List(); | ||
| 31 | frame = new Frame(); | ||
| 32 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); | ||
| 33 | frame.setSize( 350, 150 ); | ||
| 34 | frame.setVisible( true ); | ||
| 35 | } | ||
| 36 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0.1/src/Robot.java b/robottino/all_versions/v4.0.1/src/Robot.java new file mode 100755 index 0000000..6a57c4d --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/Robot.java | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class Robot { | ||
| 27 | public static Main main = new Main(); | ||
| 28 | boolean leftArm, rightArm, leftLeg, rightLeg; | ||
| 29 | String nomeRobot; | ||
| 30 | Robot precedenteRobot, prossimoRobot; | ||
| 31 | RobotFrame robotFrame; | ||
| 32 | Robot() { | ||
| 33 | this( false, false, false, false, "", main.list.ultimoRobot, null ); | ||
| 34 | } | ||
| 35 | Robot( String nome ) { | ||
| 36 | this ( false, false, false, false, nome, main.list.ultimoRobot, null ); | ||
| 37 | } | ||
| 38 | Robot( boolean la, boolean ra, boolean ll, boolean rl, String nome, Robot prec, Robot prox ) { | ||
| 39 | leftArm = la; | ||
| 40 | rightArm = ra; | ||
| 41 | leftLeg = ll; | ||
| 42 | rightLeg = rl; | ||
| 43 | nomeRobot = nome; | ||
| 44 | precedenteRobot = prec; | ||
| 45 | prossimoRobot = prox; | ||
| 46 | robotFrame = new RobotFrame( nome ); | ||
| 47 | robotFrame.setSize( 350, 600 ); | ||
| 48 | robotFrame.setVisible( true ); | ||
| 49 | robotFrame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 50 | robotFrame.addWindowListener( | ||
| 51 | new WindowAdapter() { | ||
| 52 | public void windowClosing( WindowEvent e ) { | ||
| 53 | int selezione = JOptionPane.showOptionDialog( Robot.this.robotFrame, "Eliminare il robottino " + Robot.this.getName() + " ?", "Robottino v4.0 - Cancellazione robottino", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 54 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 55 | main.list.deleteRobot( Robot.this.getName() ); | ||
| 56 | robotFrame.dispose(); | ||
| 57 | } | ||
| 58 | else { | ||
| 59 | try { | ||
| 60 | Thread.currentThread().sleep( 50 ); | ||
| 61 | } catch ( Exception e2 ) {} | ||
| 62 | robotFrame.repaint(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | ); | ||
| 67 | } | ||
| 68 | void setLA( boolean la ) { | ||
| 69 | setPositions( la, this.rightArm, this.leftLeg, this.rightLeg ); | ||
| 70 | } | ||
| 71 | void setRA( boolean ra ) { | ||
| 72 | setPositions( this.leftArm, ra, this.leftLeg, this.rightLeg ); | ||
| 73 | } | ||
| 74 | void setLL( boolean ll ) { | ||
| 75 | setPositions( this.leftArm, this.rightArm, ll, this.rightLeg ); | ||
| 76 | } | ||
| 77 | void setRL( boolean rl ) { | ||
| 78 | setPositions( this.leftArm, this.rightArm, this.leftLeg, rl ); | ||
| 79 | } | ||
| 80 | void setPositions( boolean la, boolean ra, boolean ll, boolean rl ) { | ||
| 81 | leftArm = la; | ||
| 82 | rightArm = ra; | ||
| 83 | leftLeg = ll; | ||
| 84 | rightLeg = rl; | ||
| 85 | } | ||
| 86 | void setName( String nome ) { | ||
| 87 | nomeRobot = nome; | ||
| 88 | } | ||
| 89 | boolean getLA() { | ||
| 90 | return leftArm; | ||
| 91 | } | ||
| 92 | boolean getRA() { | ||
| 93 | return rightArm; | ||
| 94 | } | ||
| 95 | boolean getLL() { | ||
| 96 | return leftLeg; | ||
| 97 | } | ||
| 98 | boolean getRL() { | ||
| 99 | return rightLeg; | ||
| 100 | } | ||
| 101 | String getName() { | ||
| 102 | return nomeRobot; | ||
| 103 | } | ||
| 104 | Robot getNext() { | ||
| 105 | return prossimoRobot; | ||
| 106 | } | ||
| 107 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0.1/src/RobotFrame.java b/robottino/all_versions/v4.0.1/src/RobotFrame.java new file mode 100755 index 0000000..df099f1 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/RobotFrame.java | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class RobotFrame extends JFrame implements ActionListener { | ||
| 27 | public static Main main; | ||
| 28 | public static RobotPanel robotPanel; | ||
| 29 | public static JMenuBar barraMenu; | ||
| 30 | public static JMenu modifica, raMenu, laMenu, rlMenu, llMenu; | ||
| 31 | public static JMenuItem raonMenuItem, raoffMenuItem, rachangeMenuItem, laonMenuItem, laoffMenuItem, lachangeMenuItem; | ||
| 32 | public static JMenuItem rlonMenuItem, rloffMenuItem, rlchangeMenuItem, llonMenuItem, lloffMenuItem, llchangeMenuItem; | ||
| 33 | RobotFrame( String titolo ) { | ||
| 34 | super ( titolo ); | ||
| 35 | robotPanel = new RobotPanel( titolo ); | ||
| 36 | raonMenuItem = new JMenuItem( "Alza" ); | ||
| 37 | laonMenuItem = new JMenuItem( "Alza" ); | ||
| 38 | rlonMenuItem = new JMenuItem( "Alza" ); | ||
| 39 | llonMenuItem = new JMenuItem( "Alza" ); | ||
| 40 | raoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 41 | laoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 42 | rloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 43 | lloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 44 | rachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 45 | lachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 46 | rlchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 47 | llchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 48 | raonMenuItem.addActionListener( this ); | ||
| 49 | raoffMenuItem.addActionListener( this ); | ||
| 50 | rachangeMenuItem.addActionListener( this ); | ||
| 51 | laonMenuItem.addActionListener( this ); | ||
| 52 | laoffMenuItem.addActionListener( this ); | ||
| 53 | lachangeMenuItem.addActionListener( this ); | ||
| 54 | rlonMenuItem.addActionListener( this ); | ||
| 55 | rloffMenuItem.addActionListener( this ); | ||
| 56 | rlchangeMenuItem.addActionListener( this ); | ||
| 57 | llonMenuItem.addActionListener( this ); | ||
| 58 | lloffMenuItem.addActionListener( this ); | ||
| 59 | llchangeMenuItem.addActionListener( this ); | ||
| 60 | raMenu = new JMenu( "Braccio destro" ); | ||
| 61 | raMenu.add( raonMenuItem ); | ||
| 62 | raMenu.add( raoffMenuItem ); | ||
| 63 | raMenu.add( rachangeMenuItem ); | ||
| 64 | laMenu = new JMenu( "Braccio sinistro" ); | ||
| 65 | laMenu.add( laonMenuItem ); | ||
| 66 | laMenu.add( laoffMenuItem ); | ||
| 67 | laMenu.add( lachangeMenuItem ); | ||
| 68 | rlMenu = new JMenu( "Gamba destra" ); | ||
| 69 | rlMenu.add( rlonMenuItem ); | ||
| 70 | rlMenu.add( rloffMenuItem ); | ||
| 71 | rlMenu.add( rlchangeMenuItem ); | ||
| 72 | llMenu = new JMenu( "Gamba sinistra" ); | ||
| 73 | llMenu.add( llonMenuItem ); | ||
| 74 | llMenu.add( lloffMenuItem ); | ||
| 75 | llMenu.add( llchangeMenuItem ); | ||
| 76 | modifica = new JMenu( "Modifica" ); | ||
| 77 | modifica.add( raMenu ); | ||
| 78 | modifica.add( laMenu ); | ||
| 79 | modifica.add( rlMenu ); | ||
| 80 | modifica.add( llMenu ); | ||
| 81 | barraMenu = new JMenuBar(); | ||
| 82 | barraMenu.add( modifica ); | ||
| 83 | setJMenuBar( barraMenu ); | ||
| 84 | add( robotPanel ); | ||
| 85 | } | ||
| 86 | public void actionPerformed( ActionEvent e ) { | ||
| 87 | esegui( e ); | ||
| 88 | } | ||
| 89 | public void esegui( ActionEvent e ) { | ||
| 90 | if ( e.getSource() == raonMenuItem ) | ||
| 91 | main.list.getRobot( this.getTitle() ).rightArm = true; | ||
| 92 | else if ( e.getSource() == raoffMenuItem ) | ||
| 93 | main.list.getRobot( this.getTitle() ).rightArm = false; | ||
| 94 | else if ( e.getSource() == rachangeMenuItem ) | ||
| 95 | main.list.getRobot( this.getTitle() ).rightArm = !main.list.getRobot( this.getTitle() ).rightArm; | ||
| 96 | else if ( e.getSource() == laonMenuItem ) | ||
| 97 | main.list.getRobot( this.getTitle() ).leftArm = true; | ||
| 98 | else if ( e.getSource() == laoffMenuItem ) | ||
| 99 | main.list.getRobot( this.getTitle() ).leftArm = false; | ||
| 100 | else if ( e.getSource() == lachangeMenuItem ) | ||
| 101 | main.list.getRobot( this.getTitle() ).leftArm = !main.list.getRobot( this.getTitle() ).leftArm; | ||
| 102 | if ( e.getSource() == rlonMenuItem ) | ||
| 103 | main.list.getRobot( this.getTitle() ).rightLeg = true; | ||
| 104 | else if ( e.getSource() == rloffMenuItem ) | ||
| 105 | main.list.getRobot( this.getTitle() ).rightLeg = false; | ||
| 106 | else if ( e.getSource() == rlchangeMenuItem ) | ||
| 107 | main.list.getRobot( this.getTitle() ).rightLeg = !main.list.getRobot( this.getTitle() ).rightLeg; | ||
| 108 | else if ( e.getSource() == llonMenuItem ) | ||
| 109 | main.list.getRobot( this.getTitle() ).leftLeg = true; | ||
| 110 | else if ( e.getSource() == lloffMenuItem ) | ||
| 111 | main.list.getRobot( this.getTitle() ).leftLeg = false; | ||
| 112 | else if ( e.getSource() == llchangeMenuItem ) | ||
| 113 | main.list.getRobot( this.getTitle() ).leftLeg = !main.list.getRobot( this.getTitle() ).leftLeg; | ||
| 114 | robotPanel.setImages(); | ||
| 115 | repaint(); | ||
| 116 | } | ||
| 117 | |||
| 118 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0.1/src/RobotPanel.java b/robottino/all_versions/v4.0.1/src/RobotPanel.java new file mode 100755 index 0000000..b66d90e --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/RobotPanel.java | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class RobotPanel extends JPanel { | ||
| 26 | public static String nomeRobot; | ||
| 27 | public static Main main; | ||
| 28 | public static ImageIcon ra, la, rl, ll, body; | ||
| 29 | public static int rax, ray, lax, lay, rlx, rly, llx, lly; | ||
| 30 | RobotPanel( String nomeRobot ) { | ||
| 31 | this.nomeRobot = nomeRobot; | ||
| 32 | rax = 66; | ||
| 33 | ray = 248; | ||
| 34 | lax = 225; | ||
| 35 | lay = 242; | ||
| 36 | rlx = 84; | ||
| 37 | rly = 367; | ||
| 38 | llx = 148; | ||
| 39 | lly = 367; | ||
| 40 | body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); | ||
| 41 | ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 42 | la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 43 | rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 44 | ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 45 | } | ||
| 46 | public void paint ( Graphics g ) { | ||
| 47 | super.paint( g ); | ||
| 48 | body.paintIcon( this, g, 100, 60 ); | ||
| 49 | ra.paintIcon( this, g, this.rax, this.ray ); | ||
| 50 | la.paintIcon( this, g, this.lax, this.lay ); | ||
| 51 | rl.paintIcon( this, g, this.rlx, this.rly ); | ||
| 52 | ll.paintIcon( this, g, this.llx, this.lly ); | ||
| 53 | } | ||
| 54 | public void setImages() { | ||
| 55 | if ( main.list.getRobot( nomeRobot ).rightArm ) { | ||
| 56 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raon.gif" ) ); | ||
| 57 | this.rax = 68; | ||
| 58 | this.ray = 128; | ||
| 59 | } | ||
| 60 | else { | ||
| 61 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 62 | this.rax = 66; | ||
| 63 | this.ray = 248; | ||
| 64 | } | ||
| 65 | if ( main.list.getRobot( nomeRobot ).leftArm ) { | ||
| 66 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laon.gif" ) ); | ||
| 67 | this.lax = 224; | ||
| 68 | this.lay = 118; | ||
| 69 | } | ||
| 70 | else { | ||
| 71 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 72 | this.lax = 225; | ||
| 73 | this.lay = 242; | ||
| 74 | } | ||
| 75 | if ( main.list.getRobot( nomeRobot ).rightLeg ) { | ||
| 76 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rlon.gif" ) ); | ||
| 77 | this.rlx = 84; | ||
| 78 | this.rly = 356; | ||
| 79 | } | ||
| 80 | else { | ||
| 81 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 82 | this.rlx = 84; | ||
| 83 | this.rly = 367; | ||
| 84 | } | ||
| 85 | if ( main.list.getRobot( nomeRobot ).leftLeg ) { | ||
| 86 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/llon.gif" ) ); | ||
| 87 | this.llx = 140; | ||
| 88 | this.lly = 363; | ||
| 89 | } | ||
| 90 | else { | ||
| 91 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 92 | this.llx = 148; | ||
| 93 | this.lly = 367; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0.1/src/img/birra1.jpg b/robottino/all_versions/v4.0.1/src/img/birra1.jpg new file mode 100755 index 0000000..6cbf8a8 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/birra1.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/birra2.jpg b/robottino/all_versions/v4.0.1/src/img/birra2.jpg new file mode 100755 index 0000000..3b3caae --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/birra2.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/birra3.jpg b/robottino/all_versions/v4.0.1/src/img/birra3.jpg new file mode 100755 index 0000000..9bc6971 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/birra3.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/birra4.jpg b/robottino/all_versions/v4.0.1/src/img/birra4.jpg new file mode 100755 index 0000000..970f2ff --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/birra4.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/birra5.gif b/robottino/all_versions/v4.0.1/src/img/birra5.gif new file mode 100755 index 0000000..6318d90 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/birra5.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/laoff.gif b/robottino/all_versions/v4.0.1/src/img/laoff.gif new file mode 100755 index 0000000..49d9db0 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/laoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/laon.gif b/robottino/all_versions/v4.0.1/src/img/laon.gif new file mode 100755 index 0000000..1880677 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/laon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/lloff.gif b/robottino/all_versions/v4.0.1/src/img/lloff.gif new file mode 100755 index 0000000..3db1ceb --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/lloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/llon.gif b/robottino/all_versions/v4.0.1/src/img/llon.gif new file mode 100755 index 0000000..ab1ff75 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/llon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/raoff.gif b/robottino/all_versions/v4.0.1/src/img/raoff.gif new file mode 100755 index 0000000..88aabc4 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/raoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/raon.gif b/robottino/all_versions/v4.0.1/src/img/raon.gif new file mode 100755 index 0000000..46190a8 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/raon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/rloff.gif b/robottino/all_versions/v4.0.1/src/img/rloff.gif new file mode 100755 index 0000000..04bda22 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/rloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/rlon.gif b/robottino/all_versions/v4.0.1/src/img/rlon.gif new file mode 100755 index 0000000..447464b --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/rlon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0.1/src/img/robot.gif b/robottino/all_versions/v4.0.1/src/img/robot.gif new file mode 100755 index 0000000..db87686 --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/img/robot.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/Robottino.jar b/robottino/all_versions/v4.0/Robottino.jar new file mode 100755 index 0000000..31b7fe8 --- /dev/null +++ b/robottino/all_versions/v4.0/Robottino.jar | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/Frame.java b/robottino/all_versions/v4.0/src/Frame.java new file mode 100755 index 0000000..8ec087b --- /dev/null +++ b/robottino/all_versions/v4.0/src/Frame.java | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | |||
| 25 | public class Frame extends JFrame { | ||
| 26 | public class Listener implements ActionListener { | ||
| 27 | public void actionPerformed( ActionEvent e ) { | ||
| 28 | if ( e.getSource() == exit ) | ||
| 29 | System.exit(0); | ||
| 30 | else if ( e.getSource() == informazioni ) | ||
| 31 | JOptionPane.showMessageDialog( main.frame, "info", "Robottino v4.0 - Informazioni", JOptionPane.INFORMATION_MESSAGE ); | ||
| 32 | else if ( e.getSource() == nuovo ) { | ||
| 33 | String nome = JOptionPane.showInputDialog( main.frame, "Inserire il nome del nuovo robottino:", "Robot " + ( ++main.robots ) ); | ||
| 34 | if ( nome != null ) | ||
| 35 | main.list.newRobot( nome ); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | public static Listener listener; | ||
| 40 | public static Main main; | ||
| 41 | public static JMenuBar barraMenu = new JMenuBar(); | ||
| 42 | public static JMenu file = new JMenu( "File" ); | ||
| 43 | public static JMenu info = new JMenu( "?" ); | ||
| 44 | public static JMenuItem exit = new JMenuItem( "Esci" ); | ||
| 45 | public static JMenuItem informazioni = new JMenuItem( "Informazioni" ); | ||
| 46 | public static JMenuItem nuovo = new JMenuItem( "Nuovo Robot" ); | ||
| 47 | public Frame() { | ||
| 48 | super( "Robottino versione 4.0" ); | ||
| 49 | listener = new Listener(); | ||
| 50 | main = new Main(); | ||
| 51 | exit.addActionListener( listener ); | ||
| 52 | exit.setMnemonic( 'E' ); | ||
| 53 | informazioni.addActionListener( listener ); | ||
| 54 | informazioni.setMnemonic( 'I' ); | ||
| 55 | nuovo.addActionListener( listener ); | ||
| 56 | nuovo.setMnemonic( 'N' ); | ||
| 57 | file.add( exit ); | ||
| 58 | file.add( nuovo ); | ||
| 59 | file.setMnemonic( 'F' ); | ||
| 60 | info.add( informazioni ); | ||
| 61 | info.setMnemonic( '?' ); | ||
| 62 | barraMenu.add( file ); | ||
| 63 | barraMenu.add( info ); | ||
| 64 | setJMenuBar( barraMenu ); | ||
| 65 | } | ||
| 66 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0/src/List.java b/robottino/all_versions/v4.0/src/List.java new file mode 100755 index 0000000..b4f9982 --- /dev/null +++ b/robottino/all_versions/v4.0/src/List.java | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JOptionPane; | ||
| 23 | |||
| 24 | public class List { | ||
| 25 | public static Main main = new Main(); | ||
| 26 | public Robot primoRobot, ultimoRobot; | ||
| 27 | public List() { | ||
| 28 | primoRobot = ultimoRobot = null; | ||
| 29 | } | ||
| 30 | public boolean vuota() { | ||
| 31 | return primoRobot == null; | ||
| 32 | } | ||
| 33 | public Robot getRobot( String nome ) { | ||
| 34 | Robot i = primoRobot; | ||
| 35 | for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ; | ||
| 36 | return i; | ||
| 37 | } | ||
| 38 | public void newRobot() { | ||
| 39 | newRobot( false, false, false, false, "" ); | ||
| 40 | } | ||
| 41 | public void newRobot( String nome ) { | ||
| 42 | newRobot( false, false, false, false, nome ); | ||
| 43 | } | ||
| 44 | public void newRobot( boolean la, boolean ra, boolean ll, boolean rl, String nome ) { | ||
| 45 | if ( vuota() ) | ||
| 46 | primoRobot = ultimoRobot = new Robot( la, ra, ll, rl, nome, null, null ); | ||
| 47 | else { | ||
| 48 | ultimoRobot = new Robot( la, ra, ll, rl, nome, ultimoRobot, null ); | ||
| 49 | ultimoRobot.precedenteRobot.prossimoRobot = ultimoRobot; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | public void deleteRobot( String nome ) { | ||
| 53 | if ( vuota() ) | ||
| 54 | JOptionPane.showMessageDialog( main.frame, "Nessun robottino presente. Impossibile cancellarne uno", "Robottino v4.0 - Errore", JOptionPane.ERROR_MESSAGE ); | ||
| 55 | else { | ||
| 56 | Robot i = primoRobot; | ||
| 57 | for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ; | ||
| 58 | if ( i.precedenteRobot != null ) | ||
| 59 | i.precedenteRobot.prossimoRobot = i.prossimoRobot; | ||
| 60 | else | ||
| 61 | primoRobot = i.prossimoRobot; | ||
| 62 | if ( i.prossimoRobot != null ) | ||
| 63 | i.prossimoRobot.precedenteRobot = i.precedenteRobot; | ||
| 64 | else | ||
| 65 | ultimoRobot = i.precedenteRobot; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | public void printList() { | ||
| 69 | String lista = ""; | ||
| 70 | for ( Robot i = primoRobot; i != null; i = i.prossimoRobot ) | ||
| 71 | lista += i.getName() + " "; | ||
| 72 | JOptionPane.showMessageDialog( main.frame, lista, "Robottino v4.0 - Robottini Presenti", JOptionPane.PLAIN_MESSAGE ); | ||
| 73 | } | ||
| 74 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0/src/Main.java b/robottino/all_versions/v4.0/src/Main.java new file mode 100755 index 0000000..4ef0206 --- /dev/null +++ b/robottino/all_versions/v4.0/src/Main.java | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JFrame; | ||
| 23 | |||
| 24 | public class Main { | ||
| 25 | public static int robots; | ||
| 26 | public static List list; | ||
| 27 | public static Frame frame; | ||
| 28 | public static void main ( String args[] ) { | ||
| 29 | robots = 0; | ||
| 30 | list = new List(); | ||
| 31 | frame = new Frame(); | ||
| 32 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); | ||
| 33 | frame.setSize( 350, 150 ); | ||
| 34 | frame.setVisible( true ); | ||
| 35 | } | ||
| 36 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0/src/Robot.java b/robottino/all_versions/v4.0/src/Robot.java new file mode 100755 index 0000000..bf0e186 --- /dev/null +++ b/robottino/all_versions/v4.0/src/Robot.java | |||
| @@ -0,0 +1,126 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class Robot { | ||
| 27 | public static Main main = new Main(); | ||
| 28 | boolean leftArm, rightArm, leftLeg, rightLeg; | ||
| 29 | String nomeRobot; | ||
| 30 | Robot precedenteRobot, prossimoRobot; | ||
| 31 | RobotFrame robotFrame; | ||
| 32 | Robot() { | ||
| 33 | this( false, false, false, false, "", main.list.ultimoRobot, null ); | ||
| 34 | } | ||
| 35 | Robot( String nome ) { | ||
| 36 | this ( false, false, false, false, nome, main.list.ultimoRobot, null ); | ||
| 37 | } | ||
| 38 | Robot( boolean la, boolean ra, boolean ll, boolean rl, String nome, Robot prec, Robot prox ) { | ||
| 39 | leftArm = la; | ||
| 40 | rightArm = ra; | ||
| 41 | leftLeg = ll; | ||
| 42 | rightLeg = rl; | ||
| 43 | nomeRobot = nome; | ||
| 44 | precedenteRobot = prec; | ||
| 45 | prossimoRobot = prox; | ||
| 46 | robotFrame = new RobotFrame( nome ); | ||
| 47 | robotFrame.setSize( 350, 550 ); | ||
| 48 | robotFrame.setVisible( true ); | ||
| 49 | robotFrame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 50 | robotFrame.addWindowListener( | ||
| 51 | new WindowAdapter() { | ||
| 52 | public void windowClosing( WindowEvent e ) { | ||
| 53 | int selezione = JOptionPane.showOptionDialog( Robot.this.robotFrame, "Eliminare il robottino " + Robot.this.getName() + " ?", "Robottino v4.0 - Cancellazione robottino", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 54 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 55 | main.list.deleteRobot( Robot.this.getName() ); | ||
| 56 | robotFrame.dispose(); | ||
| 57 | } | ||
| 58 | else { | ||
| 59 | try { | ||
| 60 | Thread.currentThread().sleep( 50 ); | ||
| 61 | } catch ( Exception e2 ) {} | ||
| 62 | robotFrame.repaint(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | public void windowActivated( WindowEvent e ) { | ||
| 66 | robotFrame.repaint(); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | ); | ||
| 70 | robotFrame.addComponentListener( | ||
| 71 | new ComponentAdapter() { | ||
| 72 | public void componentMoved( ComponentEvent e ) { | ||
| 73 | try { | ||
| 74 | Thread.currentThread().sleep( 50 ); | ||
| 75 | } catch ( Exception e2 ) {} | ||
| 76 | robotFrame.repaint(); | ||
| 77 | } | ||
| 78 | public void componentResized( ComponentEvent e ) { | ||
| 79 | try { | ||
| 80 | Thread.currentThread().sleep( 50 ); | ||
| 81 | } catch ( Exception e2 ) {} | ||
| 82 | robotFrame.repaint(); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | ); | ||
| 86 | } | ||
| 87 | void setLA( boolean la ) { | ||
| 88 | setPositions( la, this.rightArm, this.leftLeg, this.rightLeg ); | ||
| 89 | } | ||
| 90 | void setRA( boolean ra ) { | ||
| 91 | setPositions( this.leftArm, ra, this.leftLeg, this.rightLeg ); | ||
| 92 | } | ||
| 93 | void setLL( boolean ll ) { | ||
| 94 | setPositions( this.leftArm, this.rightArm, ll, this.rightLeg ); | ||
| 95 | } | ||
| 96 | void setRL( boolean rl ) { | ||
| 97 | setPositions( this.leftArm, this.rightArm, this.leftLeg, rl ); | ||
| 98 | } | ||
| 99 | void setPositions( boolean la, boolean ra, boolean ll, boolean rl ) { | ||
| 100 | leftArm = la; | ||
| 101 | rightArm = ra; | ||
| 102 | leftLeg = ll; | ||
| 103 | rightLeg = rl; | ||
| 104 | } | ||
| 105 | void setName( String nome ) { | ||
| 106 | nomeRobot = nome; | ||
| 107 | } | ||
| 108 | boolean getLA() { | ||
| 109 | return leftArm; | ||
| 110 | } | ||
| 111 | boolean getRA() { | ||
| 112 | return rightArm; | ||
| 113 | } | ||
| 114 | boolean getLL() { | ||
| 115 | return leftLeg; | ||
| 116 | } | ||
| 117 | boolean getRL() { | ||
| 118 | return rightLeg; | ||
| 119 | } | ||
| 120 | String getName() { | ||
| 121 | return nomeRobot; | ||
| 122 | } | ||
| 123 | Robot getNext() { | ||
| 124 | return prossimoRobot; | ||
| 125 | } | ||
| 126 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0/src/RobotFrame.java b/robottino/all_versions/v4.0/src/RobotFrame.java new file mode 100755 index 0000000..ad7067f --- /dev/null +++ b/robottino/all_versions/v4.0/src/RobotFrame.java | |||
| @@ -0,0 +1,179 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class RobotFrame extends JFrame implements ActionListener { | ||
| 27 | public static int rax, ray, lax, lay, rlx, rly, llx, lly; | ||
| 28 | public static Main main; | ||
| 29 | public static ImageIcon ra, la, rl, ll, body; | ||
| 30 | public static JMenuBar barraMenu; | ||
| 31 | public static JMenu modifica, raMenu, laMenu, rlMenu, llMenu; | ||
| 32 | public static JMenuItem raonMenuItem, raoffMenuItem, rachangeMenuItem, laonMenuItem, laoffMenuItem, lachangeMenuItem; | ||
| 33 | public static JMenuItem rlonMenuItem, rloffMenuItem, rlchangeMenuItem, llonMenuItem, lloffMenuItem, llchangeMenuItem; | ||
| 34 | RobotFrame( String titolo ) { | ||
| 35 | super ( titolo ); | ||
| 36 | rax = 66; | ||
| 37 | ray = 248; | ||
| 38 | lax = 225; | ||
| 39 | lay = 242; | ||
| 40 | rlx = 84; | ||
| 41 | rly = 367; | ||
| 42 | llx = 148; | ||
| 43 | lly = 367; | ||
| 44 | ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 45 | la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 46 | rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 47 | ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 48 | body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); | ||
| 49 | raonMenuItem = new JMenuItem( "Alza" ); | ||
| 50 | laonMenuItem = new JMenuItem( "Alza" ); | ||
| 51 | rlonMenuItem = new JMenuItem( "Alza" ); | ||
| 52 | llonMenuItem = new JMenuItem( "Alza" ); | ||
| 53 | raoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 54 | laoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 55 | rloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 56 | lloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 57 | rachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 58 | lachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 59 | rlchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 60 | llchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 61 | raonMenuItem.addActionListener( this ); | ||
| 62 | raoffMenuItem.addActionListener( this ); | ||
| 63 | rachangeMenuItem.addActionListener( this ); | ||
| 64 | laonMenuItem.addActionListener( this ); | ||
| 65 | laoffMenuItem.addActionListener( this ); | ||
| 66 | lachangeMenuItem.addActionListener( this ); | ||
| 67 | rlonMenuItem.addActionListener( this ); | ||
| 68 | rloffMenuItem.addActionListener( this ); | ||
| 69 | rlchangeMenuItem.addActionListener( this ); | ||
| 70 | llonMenuItem.addActionListener( this ); | ||
| 71 | lloffMenuItem.addActionListener( this ); | ||
| 72 | llchangeMenuItem.addActionListener( this ); | ||
| 73 | raMenu = new JMenu( "Braccio destro" ); | ||
| 74 | raMenu.add( raonMenuItem ); | ||
| 75 | raMenu.add( raoffMenuItem ); | ||
| 76 | raMenu.add( rachangeMenuItem ); | ||
| 77 | laMenu = new JMenu( "Braccio sinistro" ); | ||
| 78 | laMenu.add( laonMenuItem ); | ||
| 79 | laMenu.add( laoffMenuItem ); | ||
| 80 | laMenu.add( lachangeMenuItem ); | ||
| 81 | rlMenu = new JMenu( "Gamba destra" ); | ||
| 82 | rlMenu.add( rlonMenuItem ); | ||
| 83 | rlMenu.add( rloffMenuItem ); | ||
| 84 | rlMenu.add( rlchangeMenuItem ); | ||
| 85 | llMenu = new JMenu( "Gamba sinistra" ); | ||
| 86 | llMenu.add( llonMenuItem ); | ||
| 87 | llMenu.add( lloffMenuItem ); | ||
| 88 | llMenu.add( llchangeMenuItem ); | ||
| 89 | modifica = new JMenu( "Modifica" ); | ||
| 90 | modifica.add( raMenu ); | ||
| 91 | modifica.add( laMenu ); | ||
| 92 | modifica.add( rlMenu ); | ||
| 93 | modifica.add( llMenu ); | ||
| 94 | barraMenu = new JMenuBar(); | ||
| 95 | barraMenu.add( modifica ); | ||
| 96 | setJMenuBar( barraMenu ); | ||
| 97 | } | ||
| 98 | public void paint ( Graphics g ) { | ||
| 99 | super.paint( g ); | ||
| 100 | body.paintIcon( this, g, 100, 60 ); | ||
| 101 | ra.paintIcon( this, g, this.rax, this.ray ); | ||
| 102 | la.paintIcon( this, g, this.lax, this.lay ); | ||
| 103 | rl.paintIcon( this, g, this.rlx, this.rly ); | ||
| 104 | ll.paintIcon( this, g, this.llx, this.lly ); | ||
| 105 | } | ||
| 106 | public void actionPerformed( ActionEvent e ) { | ||
| 107 | esegui( e ); | ||
| 108 | } | ||
| 109 | public void esegui( ActionEvent e ) { | ||
| 110 | if ( e.getSource() == raonMenuItem ) | ||
| 111 | main.list.getRobot( this.getTitle() ).rightArm = true; | ||
| 112 | else if ( e.getSource() == raoffMenuItem ) | ||
| 113 | main.list.getRobot( this.getTitle() ).rightArm = false; | ||
| 114 | else if ( e.getSource() == rachangeMenuItem ) | ||
| 115 | main.list.getRobot( this.getTitle() ).rightArm = !main.list.getRobot( this.getTitle() ).rightArm; | ||
| 116 | else if ( e.getSource() == laonMenuItem ) | ||
| 117 | main.list.getRobot( this.getTitle() ).leftArm = true; | ||
| 118 | else if ( e.getSource() == laoffMenuItem ) | ||
| 119 | main.list.getRobot( this.getTitle() ).leftArm = false; | ||
| 120 | else if ( e.getSource() == lachangeMenuItem ) | ||
| 121 | main.list.getRobot( this.getTitle() ).leftArm = !main.list.getRobot( this.getTitle() ).leftArm; | ||
| 122 | if ( e.getSource() == rlonMenuItem ) | ||
| 123 | main.list.getRobot( this.getTitle() ).rightLeg = true; | ||
| 124 | else if ( e.getSource() == rloffMenuItem ) | ||
| 125 | main.list.getRobot( this.getTitle() ).rightLeg = false; | ||
| 126 | else if ( e.getSource() == rlchangeMenuItem ) | ||
| 127 | main.list.getRobot( this.getTitle() ).rightLeg = !main.list.getRobot( this.getTitle() ).rightLeg; | ||
| 128 | else if ( e.getSource() == llonMenuItem ) | ||
| 129 | main.list.getRobot( this.getTitle() ).leftLeg = true; | ||
| 130 | else if ( e.getSource() == lloffMenuItem ) | ||
| 131 | main.list.getRobot( this.getTitle() ).leftLeg = false; | ||
| 132 | else if ( e.getSource() == llchangeMenuItem ) | ||
| 133 | main.list.getRobot( this.getTitle() ).leftLeg = !main.list.getRobot( this.getTitle() ).leftLeg; | ||
| 134 | setImages(); | ||
| 135 | repaint(); | ||
| 136 | } | ||
| 137 | public void setImages() { | ||
| 138 | if ( main.list.getRobot( this.getTitle() ).rightArm ) { | ||
| 139 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raon.gif" ) ); | ||
| 140 | this.rax = 68; | ||
| 141 | this.ray = 128; | ||
| 142 | } | ||
| 143 | else { | ||
| 144 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 145 | this.rax = 66; | ||
| 146 | this.ray = 248; | ||
| 147 | } | ||
| 148 | if ( main.list.getRobot( this.getTitle() ).leftArm ) { | ||
| 149 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laon.gif" ) ); | ||
| 150 | this.lax = 224; | ||
| 151 | this.lay = 118; | ||
| 152 | } | ||
| 153 | else { | ||
| 154 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 155 | this.lax = 225; | ||
| 156 | this.lay = 242; | ||
| 157 | } | ||
| 158 | if ( main.list.getRobot( this.getTitle() ).rightLeg ) { | ||
| 159 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rlon.gif" ) ); | ||
| 160 | this.rlx = 84; | ||
| 161 | this.rly = 356; | ||
| 162 | } | ||
| 163 | else { | ||
| 164 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 165 | this.rlx = 84; | ||
| 166 | this.rly = 367; | ||
| 167 | } | ||
| 168 | if ( main.list.getRobot( this.getTitle() ).leftLeg ) { | ||
| 169 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/llon.gif" ) ); | ||
| 170 | this.llx = 140; | ||
| 171 | this.lly = 363; | ||
| 172 | } | ||
| 173 | else { | ||
| 174 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 175 | this.llx = 148; | ||
| 176 | this.lly = 367; | ||
| 177 | } | ||
| 178 | } | ||
| 179 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.0/src/img/laoff.gif b/robottino/all_versions/v4.0/src/img/laoff.gif new file mode 100755 index 0000000..49d9db0 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/laoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/laon.gif b/robottino/all_versions/v4.0/src/img/laon.gif new file mode 100755 index 0000000..1880677 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/laon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/lloff.gif b/robottino/all_versions/v4.0/src/img/lloff.gif new file mode 100755 index 0000000..3db1ceb --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/lloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/llon.gif b/robottino/all_versions/v4.0/src/img/llon.gif new file mode 100755 index 0000000..ab1ff75 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/llon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/raoff.gif b/robottino/all_versions/v4.0/src/img/raoff.gif new file mode 100755 index 0000000..88aabc4 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/raoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/raon.gif b/robottino/all_versions/v4.0/src/img/raon.gif new file mode 100755 index 0000000..46190a8 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/raon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/rloff.gif b/robottino/all_versions/v4.0/src/img/rloff.gif new file mode 100755 index 0000000..04bda22 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/rloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/rlon.gif b/robottino/all_versions/v4.0/src/img/rlon.gif new file mode 100755 index 0000000..447464b --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/rlon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.0/src/img/robot.gif b/robottino/all_versions/v4.0/src/img/robot.gif new file mode 100755 index 0000000..db87686 --- /dev/null +++ b/robottino/all_versions/v4.0/src/img/robot.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/Robottino.jar b/robottino/all_versions/v4.1/Robottino.jar new file mode 100755 index 0000000..61de888 --- /dev/null +++ b/robottino/all_versions/v4.1/Robottino.jar | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/license.txt b/robottino/all_versions/v4.1/license.txt new file mode 100755 index 0000000..3912109 --- /dev/null +++ b/robottino/all_versions/v4.1/license.txt | |||
| @@ -0,0 +1,340 @@ | |||
| 1 | GNU GENERAL PUBLIC LICENSE | ||
| 2 | Version 2, June 1991 | ||
| 3 | |||
| 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. | ||
| 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 6 | Everyone is permitted to copy and distribute verbatim copies | ||
| 7 | of this license document, but changing it is not allowed. | ||
| 8 | |||
| 9 | Preamble | ||
| 10 | |||
| 11 | The licenses for most software are designed to take away your | ||
| 12 | freedom to share and change it. By contrast, the GNU General Public | ||
| 13 | License is intended to guarantee your freedom to share and change free | ||
| 14 | software--to make sure the software is free for all its users. This | ||
| 15 | General Public License applies to most of the Free Software | ||
| 16 | Foundation's software and to any other program whose authors commit to | ||
| 17 | using it. (Some other Free Software Foundation software is covered by | ||
| 18 | the GNU Library General Public License instead.) You can apply it to | ||
| 19 | your programs, too. | ||
| 20 | |||
| 21 | When we speak of free software, we are referring to freedom, not | ||
| 22 | price. Our General Public Licenses are designed to make sure that you | ||
| 23 | have the freedom to distribute copies of free software (and charge for | ||
| 24 | this service if you wish), that you receive source code or can get it | ||
| 25 | if you want it, that you can change the software or use pieces of it | ||
| 26 | in new free programs; and that you know you can do these things. | ||
| 27 | |||
| 28 | To protect your rights, we need to make restrictions that forbid | ||
| 29 | anyone to deny you these rights or to ask you to surrender the rights. | ||
| 30 | These restrictions translate to certain responsibilities for you if you | ||
| 31 | distribute copies of the software, or if you modify it. | ||
| 32 | |||
| 33 | For example, if you distribute copies of such a program, whether | ||
| 34 | gratis or for a fee, you must give the recipients all the rights that | ||
| 35 | you have. You must make sure that they, too, receive or can get the | ||
| 36 | source code. And you must show them these terms so they know their | ||
| 37 | rights. | ||
| 38 | |||
| 39 | We protect your rights with two steps: (1) copyright the software, and | ||
| 40 | (2) offer you this license which gives you legal permission to copy, | ||
| 41 | distribute and/or modify the software. | ||
| 42 | |||
| 43 | Also, for each author's protection and ours, we want to make certain | ||
| 44 | that everyone understands that there is no warranty for this free | ||
| 45 | software. If the software is modified by someone else and passed on, we | ||
| 46 | want its recipients to know that what they have is not the original, so | ||
| 47 | that any problems introduced by others will not reflect on the original | ||
| 48 | authors' reputations. | ||
| 49 | |||
| 50 | Finally, any free program is threatened constantly by software | ||
| 51 | patents. We wish to avoid the danger that redistributors of a free | ||
| 52 | program will individually obtain patent licenses, in effect making the | ||
| 53 | program proprietary. To prevent this, we have made it clear that any | ||
| 54 | patent must be licensed for everyone's free use or not licensed at all. | ||
| 55 | |||
| 56 | The precise terms and conditions for copying, distribution and | ||
| 57 | modification follow. | ||
| 58 | |||
| 59 | GNU GENERAL PUBLIC LICENSE | ||
| 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
| 61 | |||
| 62 | 0. This License applies to any program or other work which contains | ||
| 63 | a notice placed by the copyright holder saying it may be distributed | ||
| 64 | under the terms of this General Public License. The "Program", below, | ||
| 65 | refers to any such program or work, and a "work based on the Program" | ||
| 66 | means either the Program or any derivative work under copyright law: | ||
| 67 | that is to say, a work containing the Program or a portion of it, | ||
| 68 | either verbatim or with modifications and/or translated into another | ||
| 69 | language. (Hereinafter, translation is included without limitation in | ||
| 70 | the term "modification".) Each licensee is addressed as "you". | ||
| 71 | |||
| 72 | Activities other than copying, distribution and modification are not | ||
| 73 | covered by this License; they are outside its scope. The act of | ||
| 74 | running the Program is not restricted, and the output from the Program | ||
| 75 | is covered only if its contents constitute a work based on the | ||
| 76 | Program (independent of having been made by running the Program). | ||
| 77 | Whether that is true depends on what the Program does. | ||
| 78 | |||
| 79 | 1. You may copy and distribute verbatim copies of the Program's | ||
| 80 | source code as you receive it, in any medium, provided that you | ||
| 81 | conspicuously and appropriately publish on each copy an appropriate | ||
| 82 | copyright notice and disclaimer of warranty; keep intact all the | ||
| 83 | notices that refer to this License and to the absence of any warranty; | ||
| 84 | and give any other recipients of the Program a copy of this License | ||
| 85 | along with the Program. | ||
| 86 | |||
| 87 | You may charge a fee for the physical act of transferring a copy, and | ||
| 88 | you may at your option offer warranty protection in exchange for a fee. | ||
| 89 | |||
| 90 | 2. You may modify your copy or copies of the Program or any portion | ||
| 91 | of it, thus forming a work based on the Program, and copy and | ||
| 92 | distribute such modifications or work under the terms of Section 1 | ||
| 93 | above, provided that you also meet all of these conditions: | ||
| 94 | |||
| 95 | a) You must cause the modified files to carry prominent notices | ||
| 96 | stating that you changed the files and the date of any change. | ||
| 97 | |||
| 98 | b) You must cause any work that you distribute or publish, that in | ||
| 99 | whole or in part contains or is derived from the Program or any | ||
| 100 | part thereof, to be licensed as a whole at no charge to all third | ||
| 101 | parties under the terms of this License. | ||
| 102 | |||
| 103 | c) If the modified program normally reads commands interactively | ||
| 104 | when run, you must cause it, when started running for such | ||
| 105 | interactive use in the most ordinary way, to print or display an | ||
| 106 | announcement including an appropriate copyright notice and a | ||
| 107 | notice that there is no warranty (or else, saying that you provide | ||
| 108 | a warranty) and that users may redistribute the program under | ||
| 109 | these conditions, and telling the user how to view a copy of this | ||
| 110 | License. (Exception: if the Program itself is interactive but | ||
| 111 | does not normally print such an announcement, your work based on | ||
| 112 | the Program is not required to print an announcement.) | ||
| 113 | |||
| 114 | These requirements apply to the modified work as a whole. If | ||
| 115 | identifiable sections of that work are not derived from the Program, | ||
| 116 | and can be reasonably considered independent and separate works in | ||
| 117 | themselves, then this License, and its terms, do not apply to those | ||
| 118 | sections when you distribute them as separate works. But when you | ||
| 119 | distribute the same sections as part of a whole which is a work based | ||
| 120 | on the Program, the distribution of the whole must be on the terms of | ||
| 121 | this License, whose permissions for other licensees extend to the | ||
| 122 | entire whole, and thus to each and every part regardless of who wrote it. | ||
| 123 | |||
| 124 | Thus, it is not the intent of this section to claim rights or contest | ||
| 125 | your rights to work written entirely by you; rather, the intent is to | ||
| 126 | exercise the right to control the distribution of derivative or | ||
| 127 | collective works based on the Program. | ||
| 128 | |||
| 129 | In addition, mere aggregation of another work not based on the Program | ||
| 130 | with the Program (or with a work based on the Program) on a volume of | ||
| 131 | a storage or distribution medium does not bring the other work under | ||
| 132 | the scope of this License. | ||
| 133 | |||
| 134 | 3. You may copy and distribute the Program (or a work based on it, | ||
| 135 | under Section 2) in object code or executable form under the terms of | ||
| 136 | Sections 1 and 2 above provided that you also do one of the following: | ||
| 137 | |||
| 138 | a) Accompany it with the complete corresponding machine-readable | ||
| 139 | source code, which must be distributed under the terms of Sections | ||
| 140 | 1 and 2 above on a medium customarily used for software interchange; or, | ||
| 141 | |||
| 142 | b) Accompany it with a written offer, valid for at least three | ||
| 143 | years, to give any third party, for a charge no more than your | ||
| 144 | cost of physically performing source distribution, a complete | ||
| 145 | machine-readable copy of the corresponding source code, to be | ||
| 146 | distributed under the terms of Sections 1 and 2 above on a medium | ||
| 147 | customarily used for software interchange; or, | ||
| 148 | |||
| 149 | c) Accompany it with the information you received as to the offer | ||
| 150 | to distribute corresponding source code. (This alternative is | ||
| 151 | allowed only for noncommercial distribution and only if you | ||
| 152 | received the program in object code or executable form with such | ||
| 153 | an offer, in accord with Subsection b above.) | ||
| 154 | |||
| 155 | The source code for a work means the preferred form of the work for | ||
| 156 | making modifications to it. For an executable work, complete source | ||
| 157 | code means all the source code for all modules it contains, plus any | ||
| 158 | associated interface definition files, plus the scripts used to | ||
| 159 | control compilation and installation of the executable. However, as a | ||
| 160 | special exception, the source code distributed need not include | ||
| 161 | anything that is normally distributed (in either source or binary | ||
| 162 | form) with the major components (compiler, kernel, and so on) of the | ||
| 163 | operating system on which the executable runs, unless that component | ||
| 164 | itself accompanies the executable. | ||
| 165 | |||
| 166 | If distribution of executable or object code is made by offering | ||
| 167 | access to copy from a designated place, then offering equivalent | ||
| 168 | access to copy the source code from the same place counts as | ||
| 169 | distribution of the source code, even though third parties are not | ||
| 170 | compelled to copy the source along with the object code. | ||
| 171 | |||
| 172 | 4. You may not copy, modify, sublicense, or distribute the Program | ||
| 173 | except as expressly provided under this License. Any attempt | ||
| 174 | otherwise to copy, modify, sublicense or distribute the Program is | ||
| 175 | void, and will automatically terminate your rights under this License. | ||
| 176 | However, parties who have received copies, or rights, from you under | ||
| 177 | this License will not have their licenses terminated so long as such | ||
| 178 | parties remain in full compliance. | ||
| 179 | |||
| 180 | 5. You are not required to accept this License, since you have not | ||
| 181 | signed it. However, nothing else grants you permission to modify or | ||
| 182 | distribute the Program or its derivative works. These actions are | ||
| 183 | prohibited by law if you do not accept this License. Therefore, by | ||
| 184 | modifying or distributing the Program (or any work based on the | ||
| 185 | Program), you indicate your acceptance of this License to do so, and | ||
| 186 | all its terms and conditions for copying, distributing or modifying | ||
| 187 | the Program or works based on it. | ||
| 188 | |||
| 189 | 6. Each time you redistribute the Program (or any work based on the | ||
| 190 | Program), the recipient automatically receives a license from the | ||
| 191 | original licensor to copy, distribute or modify the Program subject to | ||
| 192 | these terms and conditions. You may not impose any further | ||
| 193 | restrictions on the recipients' exercise of the rights granted herein. | ||
| 194 | You are not responsible for enforcing compliance by third parties to | ||
| 195 | this License. | ||
| 196 | |||
| 197 | 7. If, as a consequence of a court judgment or allegation of patent | ||
| 198 | infringement or for any other reason (not limited to patent issues), | ||
| 199 | conditions are imposed on you (whether by court order, agreement or | ||
| 200 | otherwise) that contradict the conditions of this License, they do not | ||
| 201 | excuse you from the conditions of this License. If you cannot | ||
| 202 | distribute so as to satisfy simultaneously your obligations under this | ||
| 203 | License and any other pertinent obligations, then as a consequence you | ||
| 204 | may not distribute the Program at all. For example, if a patent | ||
| 205 | license would not permit royalty-free redistribution of the Program by | ||
| 206 | all those who receive copies directly or indirectly through you, then | ||
| 207 | the only way you could satisfy both it and this License would be to | ||
| 208 | refrain entirely from distribution of the Program. | ||
| 209 | |||
| 210 | If any portion of this section is held invalid or unenforceable under | ||
| 211 | any particular circumstance, the balance of the section is intended to | ||
| 212 | apply and the section as a whole is intended to apply in other | ||
| 213 | circumstances. | ||
| 214 | |||
| 215 | It is not the purpose of this section to induce you to infringe any | ||
| 216 | patents or other property right claims or to contest validity of any | ||
| 217 | such claims; this section has the sole purpose of protecting the | ||
| 218 | integrity of the free software distribution system, which is | ||
| 219 | implemented by public license practices. Many people have made | ||
| 220 | generous contributions to the wide range of software distributed | ||
| 221 | through that system in reliance on consistent application of that | ||
| 222 | system; it is up to the author/donor to decide if he or she is willing | ||
| 223 | to distribute software through any other system and a licensee cannot | ||
| 224 | impose that choice. | ||
| 225 | |||
| 226 | This section is intended to make thoroughly clear what is believed to | ||
| 227 | be a consequence of the rest of this License. | ||
| 228 | |||
| 229 | 8. If the distribution and/or use of the Program is restricted in | ||
| 230 | certain countries either by patents or by copyrighted interfaces, the | ||
| 231 | original copyright holder who places the Program under this License | ||
| 232 | may add an explicit geographical distribution limitation excluding | ||
| 233 | those countries, so that distribution is permitted only in or among | ||
| 234 | countries not thus excluded. In such case, this License incorporates | ||
| 235 | the limitation as if written in the body of this License. | ||
| 236 | |||
| 237 | 9. The Free Software Foundation may publish revised and/or new versions | ||
| 238 | of the General Public License from time to time. Such new versions will | ||
| 239 | be similar in spirit to the present version, but may differ in detail to | ||
| 240 | address new problems or concerns. | ||
| 241 | |||
| 242 | Each version is given a distinguishing version number. If the Program | ||
| 243 | specifies a version number of this License which applies to it and "any | ||
| 244 | later version", you have the option of following the terms and conditions | ||
| 245 | either of that version or of any later version published by the Free | ||
| 246 | Software Foundation. If the Program does not specify a version number of | ||
| 247 | this License, you may choose any version ever published by the Free Software | ||
| 248 | Foundation. | ||
| 249 | |||
| 250 | 10. If you wish to incorporate parts of the Program into other free | ||
| 251 | programs whose distribution conditions are different, write to the author | ||
| 252 | to ask for permission. For software which is copyrighted by the Free | ||
| 253 | Software Foundation, write to the Free Software Foundation; we sometimes | ||
| 254 | make exceptions for this. Our decision will be guided by the two goals | ||
| 255 | of preserving the free status of all derivatives of our free software and | ||
| 256 | of promoting the sharing and reuse of software generally. | ||
| 257 | |||
| 258 | NO WARRANTY | ||
| 259 | |||
| 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||
| 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | ||
| 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||
| 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | ||
| 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | ||
| 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | ||
| 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | ||
| 268 | REPAIR OR CORRECTION. | ||
| 269 | |||
| 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
| 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||
| 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | ||
| 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | ||
| 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | ||
| 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | ||
| 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | ||
| 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | ||
| 278 | POSSIBILITY OF SUCH DAMAGES. | ||
| 279 | |||
| 280 | END OF TERMS AND CONDITIONS | ||
| 281 | |||
| 282 | How to Apply These Terms to Your New Programs | ||
| 283 | |||
| 284 | If you develop a new program, and you want it to be of the greatest | ||
| 285 | possible use to the public, the best way to achieve this is to make it | ||
| 286 | free software which everyone can redistribute and change under these terms. | ||
| 287 | |||
| 288 | To do so, attach the following notices to the program. It is safest | ||
| 289 | to attach them to the start of each source file to most effectively | ||
| 290 | convey the exclusion of warranty; and each file should have at least | ||
| 291 | the "copyright" line and a pointer to where the full notice is found. | ||
| 292 | |||
| 293 | <one line to give the program's name and a brief idea of what it does.> | ||
| 294 | Copyright (C) <year> <name of author> | ||
| 295 | |||
| 296 | This program is free software; you can redistribute it and/or modify | ||
| 297 | it under the terms of the GNU General Public License as published by | ||
| 298 | the Free Software Foundation; either version 2 of the License, or | ||
| 299 | (at your option) any later version. | ||
| 300 | |||
| 301 | This program is distributed in the hope that it will be useful, | ||
| 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 304 | GNU General Public License for more details. | ||
| 305 | |||
| 306 | You should have received a copy of the GNU General Public License | ||
| 307 | along with this program; if not, write to the Free Software | ||
| 308 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 309 | |||
| 310 | |||
| 311 | Also add information on how to contact you by electronic and paper mail. | ||
| 312 | |||
| 313 | If the program is interactive, make it output a short notice like this | ||
| 314 | when it starts in an interactive mode: | ||
| 315 | |||
| 316 | Gnomovision version 69, Copyright (C) year name of author | ||
| 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
| 318 | This is free software, and you are welcome to redistribute it | ||
| 319 | under certain conditions; type `show c' for details. | ||
| 320 | |||
| 321 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
| 322 | parts of the General Public License. Of course, the commands you use may | ||
| 323 | be called something other than `show w' and `show c'; they could even be | ||
| 324 | mouse-clicks or menu items--whatever suits your program. | ||
| 325 | |||
| 326 | You should also get your employer (if you work as a programmer) or your | ||
| 327 | school, if any, to sign a "copyright disclaimer" for the program, if | ||
| 328 | necessary. Here is a sample; alter the names: | ||
| 329 | |||
| 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program | ||
| 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. | ||
| 332 | |||
| 333 | <signature of Ty Coon>, 1 April 1989 | ||
| 334 | Ty Coon, President of Vice | ||
| 335 | |||
| 336 | This General Public License does not permit incorporating your program into | ||
| 337 | proprietary programs. If your program is a subroutine library, you may | ||
| 338 | consider it more useful to permit linking proprietary applications with the | ||
| 339 | library. If this is what you want to do, use the GNU Library General | ||
| 340 | Public License instead of this License. | ||
diff --git a/robottino/all_versions/v4.1/src/Frame.java b/robottino/all_versions/v4.1/src/Frame.java new file mode 100755 index 0000000..a5283c1 --- /dev/null +++ b/robottino/all_versions/v4.1/src/Frame.java | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | |||
| 25 | public class Frame extends JFrame { | ||
| 26 | public static Listener listener; | ||
| 27 | public static Main main; | ||
| 28 | public static JMenuBar barraMenu = new JMenuBar(); | ||
| 29 | public static JMenu file = new JMenu( "File" ); | ||
| 30 | public static JMenu info = new JMenu( "?" ); | ||
| 31 | public static JMenuItem exit = new JMenuItem( "Esci" ); | ||
| 32 | public static JMenuItem informazioni = new JMenuItem( "Informazioni" ); | ||
| 33 | public static JMenuItem nuovo = new JMenuItem( "Nuovo Robot" ); | ||
| 34 | public Frame() { | ||
| 35 | super( "Robottino versione 4.1" ); | ||
| 36 | listener = new Listener(); | ||
| 37 | main = new Main(); | ||
| 38 | exit.addActionListener( listener ); | ||
| 39 | exit.setMnemonic( 'E' ); | ||
| 40 | informazioni.addActionListener( listener ); | ||
| 41 | informazioni.setMnemonic( 'I' ); | ||
| 42 | nuovo.addActionListener( listener ); | ||
| 43 | nuovo.setMnemonic( 'N' ); | ||
| 44 | file.add( exit ); | ||
| 45 | file.add( nuovo ); | ||
| 46 | file.setMnemonic( 'F' ); | ||
| 47 | info.add( informazioni ); | ||
| 48 | info.setMnemonic( '?' ); | ||
| 49 | barraMenu.add( file ); | ||
| 50 | barraMenu.add( info ); | ||
| 51 | setJMenuBar( barraMenu ); | ||
| 52 | } | ||
| 53 | public class Listener implements ActionListener { | ||
| 54 | public void actionPerformed( ActionEvent e ) { | ||
| 55 | if ( e.getSource() == exit ) | ||
| 56 | System.exit(0); | ||
| 57 | else if ( e.getSource() == informazioni ) | ||
| 58 | JOptionPane.showMessageDialog( main.frame, "info", "Robottino v4.1 - Informazioni", JOptionPane.INFORMATION_MESSAGE ); | ||
| 59 | else if ( e.getSource() == nuovo ) { | ||
| 60 | String nome = JOptionPane.showInputDialog( main.frame, "Inserire il nome del nuovo robottino:", "Robot " + ( ++main.robots ) ); | ||
| 61 | if ( nome != null ) | ||
| 62 | main.list.newRobot( nome ); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.1/src/List.java b/robottino/all_versions/v4.1/src/List.java new file mode 100755 index 0000000..13a8ab6 --- /dev/null +++ b/robottino/all_versions/v4.1/src/List.java | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JOptionPane; | ||
| 23 | |||
| 24 | public class List { | ||
| 25 | public static Main main = new Main(); | ||
| 26 | public Robot primoRobot, ultimoRobot; | ||
| 27 | public List() { | ||
| 28 | primoRobot = ultimoRobot = null; | ||
| 29 | } | ||
| 30 | public boolean vuota() { | ||
| 31 | return primoRobot == null; | ||
| 32 | } | ||
| 33 | public Robot getRobot( String nome ) { | ||
| 34 | Robot i = primoRobot; | ||
| 35 | for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ; | ||
| 36 | return i; | ||
| 37 | } | ||
| 38 | public void newRobot() { | ||
| 39 | newRobot( false, false, false, false, "" ); | ||
| 40 | } | ||
| 41 | public void newRobot( String nome ) { | ||
| 42 | newRobot( false, false, false, false, nome ); | ||
| 43 | } | ||
| 44 | public void newRobot( boolean la, boolean ra, boolean ll, boolean rl, String nome ) { | ||
| 45 | if ( vuota() ) | ||
| 46 | primoRobot = ultimoRobot = new Robot( la, ra, ll, rl, nome, null, null ); | ||
| 47 | else { | ||
| 48 | ultimoRobot = new Robot( la, ra, ll, rl, nome, ultimoRobot, null ); | ||
| 49 | ultimoRobot.precedenteRobot.prossimoRobot = ultimoRobot; | ||
| 50 | } | ||
| 51 | } | ||
| 52 | public void deleteRobot( String nome ) { | ||
| 53 | if ( vuota() ) | ||
| 54 | JOptionPane.showMessageDialog( main.frame, "Nessun robottino presente. Impossibile cancellarne uno", "Robottino v4.1 - Errore", JOptionPane.ERROR_MESSAGE ); | ||
| 55 | else { | ||
| 56 | Robot i = primoRobot; | ||
| 57 | for ( ; !i.nomeRobot.equals( nome ); i = i.prossimoRobot ) ; | ||
| 58 | if ( i.precedenteRobot != null ) | ||
| 59 | i.precedenteRobot.prossimoRobot = i.prossimoRobot; | ||
| 60 | else | ||
| 61 | primoRobot = i.prossimoRobot; | ||
| 62 | if ( i.prossimoRobot != null ) | ||
| 63 | i.prossimoRobot.precedenteRobot = i.precedenteRobot; | ||
| 64 | else | ||
| 65 | ultimoRobot = i.precedenteRobot; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | public void printList() { | ||
| 69 | String lista = ""; | ||
| 70 | for ( Robot i = primoRobot; i != null; i = i.prossimoRobot ) | ||
| 71 | lista += i.getName() + " "; | ||
| 72 | JOptionPane.showMessageDialog( main.frame, lista, "Robottino v4.1 - Robottini Presenti", JOptionPane.PLAIN_MESSAGE ); | ||
| 73 | } | ||
| 74 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.1/src/Main.java b/robottino/all_versions/v4.1/src/Main.java new file mode 100755 index 0000000..4ef0206 --- /dev/null +++ b/robottino/all_versions/v4.1/src/Main.java | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JFrame; | ||
| 23 | |||
| 24 | public class Main { | ||
| 25 | public static int robots; | ||
| 26 | public static List list; | ||
| 27 | public static Frame frame; | ||
| 28 | public static void main ( String args[] ) { | ||
| 29 | robots = 0; | ||
| 30 | list = new List(); | ||
| 31 | frame = new Frame(); | ||
| 32 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); | ||
| 33 | frame.setSize( 350, 150 ); | ||
| 34 | frame.setVisible( true ); | ||
| 35 | } | ||
| 36 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.1/src/Robot.java b/robottino/all_versions/v4.1/src/Robot.java new file mode 100755 index 0000000..c52f29c --- /dev/null +++ b/robottino/all_versions/v4.1/src/Robot.java | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class Robot { | ||
| 27 | public static Main main = new Main(); | ||
| 28 | boolean leftArm, rightArm, leftLeg, rightLeg; | ||
| 29 | String nomeRobot; | ||
| 30 | Robot precedenteRobot, prossimoRobot; | ||
| 31 | RobotFrame robotFrame; | ||
| 32 | Robot() { | ||
| 33 | this( false, false, false, false, "", main.list.ultimoRobot, null ); | ||
| 34 | } | ||
| 35 | Robot( String nome ) { | ||
| 36 | this ( false, false, false, false, nome, main.list.ultimoRobot, null ); | ||
| 37 | } | ||
| 38 | Robot( boolean la, boolean ra, boolean ll, boolean rl, String nome, Robot prec, Robot prox ) { | ||
| 39 | leftArm = la; | ||
| 40 | rightArm = ra; | ||
| 41 | leftLeg = ll; | ||
| 42 | rightLeg = rl; | ||
| 43 | nomeRobot = nome; | ||
| 44 | precedenteRobot = prec; | ||
| 45 | prossimoRobot = prox; | ||
| 46 | robotFrame = new RobotFrame( nome ); | ||
| 47 | robotFrame.setSize( 350, 600 ); | ||
| 48 | robotFrame.setVisible( true ); | ||
| 49 | robotFrame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 50 | robotFrame.addWindowListener( | ||
| 51 | new WindowAdapter() { | ||
| 52 | public void windowClosing( WindowEvent e ) { | ||
| 53 | int selezione = JOptionPane.showOptionDialog( Robot.this.robotFrame, "Eliminare il robottino " + Robot.this.getName() + " ?", "Robottino v4.1 - Cancellazione robottino", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 54 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 55 | main.list.deleteRobot( Robot.this.getName() ); | ||
| 56 | robotFrame.dispose(); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | } | ||
| 60 | ); | ||
| 61 | } | ||
| 62 | void setLA( boolean la ) { | ||
| 63 | setPositions( la, this.rightArm, this.leftLeg, this.rightLeg ); | ||
| 64 | } | ||
| 65 | void setRA( boolean ra ) { | ||
| 66 | setPositions( this.leftArm, ra, this.leftLeg, this.rightLeg ); | ||
| 67 | } | ||
| 68 | void setLL( boolean ll ) { | ||
| 69 | setPositions( this.leftArm, this.rightArm, ll, this.rightLeg ); | ||
| 70 | } | ||
| 71 | void setRL( boolean rl ) { | ||
| 72 | setPositions( this.leftArm, this.rightArm, this.leftLeg, rl ); | ||
| 73 | } | ||
| 74 | void setPositions( boolean la, boolean ra, boolean ll, boolean rl ) { | ||
| 75 | this.leftArm = la; | ||
| 76 | this.rightArm = ra; | ||
| 77 | this.leftLeg = ll; | ||
| 78 | this.rightLeg = rl; | ||
| 79 | } | ||
| 80 | void setName( String nome ) { | ||
| 81 | nomeRobot = nome; | ||
| 82 | } | ||
| 83 | boolean getLA() { | ||
| 84 | return leftArm; | ||
| 85 | } | ||
| 86 | boolean getRA() { | ||
| 87 | return rightArm; | ||
| 88 | } | ||
| 89 | boolean getLL() { | ||
| 90 | return leftLeg; | ||
| 91 | } | ||
| 92 | boolean getRL() { | ||
| 93 | return rightLeg; | ||
| 94 | } | ||
| 95 | String getName() { | ||
| 96 | return nomeRobot; | ||
| 97 | } | ||
| 98 | Robot getNext() { | ||
| 99 | return prossimoRobot; | ||
| 100 | } | ||
| 101 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.1/src/RobotFrame.java b/robottino/all_versions/v4.1/src/RobotFrame.java new file mode 100755 index 0000000..c8cbf13 --- /dev/null +++ b/robottino/all_versions/v4.1/src/RobotFrame.java | |||
| @@ -0,0 +1,312 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class RobotFrame extends JFrame implements ActionListener { | ||
| 27 | public static int numeroCopie, i; | ||
| 28 | public static Main main; | ||
| 29 | public static RobotPanel robotPanel; | ||
| 30 | public static Timer timer; | ||
| 31 | public static JMenuBar barraMenu; | ||
| 32 | public static JMenu file, modifica, azioni, info, raMenu, laMenu, rlMenu, llMenu; | ||
| 33 | public static JMenuItem raonMenuItem, raoffMenuItem, rachangeMenuItem, laonMenuItem, laoffMenuItem, lachangeMenuItem; | ||
| 34 | public static JMenuItem rlonMenuItem, rloffMenuItem, rlchangeMenuItem, llonMenuItem, lloffMenuItem, llchangeMenuItem; | ||
| 35 | public static JMenuItem rinomina, elimina, duplica, birra, balla, esplodi, informazioni; | ||
| 36 | RobotFrame( String titolo ) { | ||
| 37 | super ( titolo ); | ||
| 38 | numeroCopie = 0; | ||
| 39 | robotPanel = new RobotPanel( titolo ); | ||
| 40 | rinomina = new JMenuItem( "Cambia nome" ); | ||
| 41 | elimina = new JMenuItem( "Elimina" ); | ||
| 42 | duplica = new JMenuItem( "Duplica robot" ); | ||
| 43 | birra = new JMenuItem( "Birra" ); | ||
| 44 | balla = new JMenuItem( "Balla" ); | ||
| 45 | esplodi = new JMenuItem( "Esplodi" ); | ||
| 46 | informazioni = new JMenuItem( "Informazioni" ); | ||
| 47 | raonMenuItem = new JMenuItem( "Alza" ); | ||
| 48 | laonMenuItem = new JMenuItem( "Alza" ); | ||
| 49 | rlonMenuItem = new JMenuItem( "Alza" ); | ||
| 50 | llonMenuItem = new JMenuItem( "Alza" ); | ||
| 51 | raoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 52 | laoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 53 | rloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 54 | lloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 55 | rachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 56 | lachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 57 | rlchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 58 | llchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 59 | rinomina.addActionListener( this ); | ||
| 60 | elimina.addActionListener( this ); | ||
| 61 | duplica.addActionListener( this ); | ||
| 62 | birra.addActionListener( this ); | ||
| 63 | balla.addActionListener( this ); | ||
| 64 | esplodi.addActionListener( this ); | ||
| 65 | informazioni.addActionListener( this ); | ||
| 66 | raonMenuItem.addActionListener( this ); | ||
| 67 | raoffMenuItem.addActionListener( this ); | ||
| 68 | rachangeMenuItem.addActionListener( this ); | ||
| 69 | laonMenuItem.addActionListener( this ); | ||
| 70 | laoffMenuItem.addActionListener( this ); | ||
| 71 | lachangeMenuItem.addActionListener( this ); | ||
| 72 | rlonMenuItem.addActionListener( this ); | ||
| 73 | rloffMenuItem.addActionListener( this ); | ||
| 74 | rlchangeMenuItem.addActionListener( this ); | ||
| 75 | llonMenuItem.addActionListener( this ); | ||
| 76 | lloffMenuItem.addActionListener( this ); | ||
| 77 | llchangeMenuItem.addActionListener( this ); | ||
| 78 | raMenu = new JMenu( "Braccio destro" ); | ||
| 79 | raMenu.add( raonMenuItem ); | ||
| 80 | raMenu.add( raoffMenuItem ); | ||
| 81 | raMenu.add( rachangeMenuItem ); | ||
| 82 | laMenu = new JMenu( "Braccio sinistro" ); | ||
| 83 | laMenu.add( laonMenuItem ); | ||
| 84 | laMenu.add( laoffMenuItem ); | ||
| 85 | laMenu.add( lachangeMenuItem ); | ||
| 86 | rlMenu = new JMenu( "Gamba destra" ); | ||
| 87 | rlMenu.add( rlonMenuItem ); | ||
| 88 | rlMenu.add( rloffMenuItem ); | ||
| 89 | rlMenu.add( rlchangeMenuItem ); | ||
| 90 | llMenu = new JMenu( "Gamba sinistra" ); | ||
| 91 | llMenu.add( llonMenuItem ); | ||
| 92 | llMenu.add( lloffMenuItem ); | ||
| 93 | llMenu.add( llchangeMenuItem ); | ||
| 94 | modifica = new JMenu( "Modifica" ); | ||
| 95 | modifica.add( raMenu ); | ||
| 96 | modifica.add( laMenu ); | ||
| 97 | modifica.add( rlMenu ); | ||
| 98 | modifica.add( llMenu ); | ||
| 99 | file = new JMenu( "File" ); | ||
| 100 | file.add( rinomina ); | ||
| 101 | file.add( duplica ); | ||
| 102 | file.add( elimina ); | ||
| 103 | azioni = new JMenu( "Azioni" ); | ||
| 104 | azioni.add( birra ); | ||
| 105 | azioni.add( balla ); | ||
| 106 | azioni.add( esplodi ); | ||
| 107 | info = new JMenu( "?" ); | ||
| 108 | info.add( informazioni ); | ||
| 109 | barraMenu = new JMenuBar(); | ||
| 110 | barraMenu.add( file ); | ||
| 111 | barraMenu.add( azioni ); | ||
| 112 | barraMenu.add( modifica ); | ||
| 113 | barraMenu.add( info ); | ||
| 114 | setJMenuBar( barraMenu ); | ||
| 115 | add( robotPanel ); | ||
| 116 | } | ||
| 117 | public void actionPerformed( ActionEvent e ) { | ||
| 118 | esegui( e ); | ||
| 119 | } | ||
| 120 | public void esegui( ActionEvent e ) { | ||
| 121 | if ( e.getSource() == raonMenuItem ) | ||
| 122 | main.list.getRobot( this.getTitle() ).rightArm = true; | ||
| 123 | else if ( e.getSource() == raoffMenuItem ) | ||
| 124 | main.list.getRobot( this.getTitle() ).rightArm = false; | ||
| 125 | else if ( e.getSource() == rachangeMenuItem ) | ||
| 126 | main.list.getRobot( this.getTitle() ).rightArm = !main.list.getRobot( this.getTitle() ).rightArm; | ||
| 127 | else if ( e.getSource() == laonMenuItem ) | ||
| 128 | main.list.getRobot( this.getTitle() ).leftArm = true; | ||
| 129 | else if ( e.getSource() == laoffMenuItem ) | ||
| 130 | main.list.getRobot( this.getTitle() ).leftArm = false; | ||
| 131 | else if ( e.getSource() == lachangeMenuItem ) | ||
| 132 | main.list.getRobot( this.getTitle() ).leftArm = !main.list.getRobot( this.getTitle() ).leftArm; | ||
| 133 | else if ( e.getSource() == rlonMenuItem ) | ||
| 134 | main.list.getRobot( this.getTitle() ).rightLeg = true; | ||
| 135 | else if ( e.getSource() == rloffMenuItem ) | ||
| 136 | main.list.getRobot( this.getTitle() ).rightLeg = false; | ||
| 137 | else if ( e.getSource() == rlchangeMenuItem ) | ||
| 138 | main.list.getRobot( this.getTitle() ).rightLeg = !main.list.getRobot( this.getTitle() ).rightLeg; | ||
| 139 | else if ( e.getSource() == llonMenuItem ) | ||
| 140 | main.list.getRobot( this.getTitle() ).leftLeg = true; | ||
| 141 | else if ( e.getSource() == lloffMenuItem ) | ||
| 142 | main.list.getRobot( this.getTitle() ).leftLeg = false; | ||
| 143 | else if ( e.getSource() == llchangeMenuItem ) | ||
| 144 | main.list.getRobot( this.getTitle() ).leftLeg = !main.list.getRobot( this.getTitle() ).leftLeg; | ||
| 145 | else if ( e.getSource() == rinomina ) { | ||
| 146 | String newName = JOptionPane.showInputDialog( this, "Inserire il nuovo nome per questo robot:", this.getTitle() ); | ||
| 147 | if ( newName != null ) { | ||
| 148 | main.list.getRobot( this.getTitle() ).setName( newName ); | ||
| 149 | this.setTitle( newName ); | ||
| 150 | robotPanel.nomeRobot = newName; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | else if ( e.getSource() == elimina ) { | ||
| 154 | int selezione = JOptionPane.showOptionDialog( this, "Eliminare il robottino " + this.getTitle() + " ?", "Robottino v4.1 - Cancellazione robottino", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 155 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 156 | main.list.deleteRobot( this.getTitle() ); | ||
| 157 | this.dispose(); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | else if ( e.getSource() == duplica ) { | ||
| 161 | String newName = JOptionPane.showInputDialog( this, "Inserire il nome per il nuovo robot:", this.getTitle() + " #" + (++numeroCopie) ); | ||
| 162 | if ( newName != null ) { | ||
| 163 | main.list.newRobot( main.list.getRobot( this.getTitle() ).leftArm, main.list.getRobot( this.getTitle() ).rightArm, main.list.getRobot( this.getTitle() ).leftLeg, main.list.getRobot( this.getTitle() ).rightLeg, newName ); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | else if ( e.getSource() == birra ) { | ||
| 167 | ImageIcon birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra5.gif" ) ); | ||
| 168 | JOptionPane.showMessageDialog( this, "", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 169 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra1.jpg" ) ); | ||
| 170 | JOptionPane.showMessageDialog( this, "", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 171 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra2.jpg" ) ); | ||
| 172 | JOptionPane.showMessageDialog( this, "", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 173 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra3.jpg" ) ); | ||
| 174 | JOptionPane.showMessageDialog( this, "", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 175 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra4.jpg" ) ); | ||
| 176 | JOptionPane.showMessageDialog( this, "", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 177 | JOptionPane.showMessageDialog( this, "Che bevuta!", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE ); | ||
| 178 | JOptionPane.showMessageDialog( this, "Buuuuuuurp!", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE ); | ||
| 179 | robotPanel.body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); | ||
| 180 | } | ||
| 181 | else if ( e.getSource() == balla ) { | ||
| 182 | this.i = 0; | ||
| 183 | main.list.getRobot( this.getTitle() ).setPositions( false, false, false, false ); | ||
| 184 | timer = new Timer( 250, | ||
| 185 | new ActionListener() { | ||
| 186 | public void actionPerformed( ActionEvent e ) { | ||
| 187 | RobotFrame.this.i++; | ||
| 188 | switch( RobotFrame.this.i ) { | ||
| 189 | case 1: | ||
| 190 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setRA( true ); | ||
| 191 | break; | ||
| 192 | case 2: | ||
| 193 | break; | ||
| 194 | case 3: | ||
| 195 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setLA( true ); | ||
| 196 | break; | ||
| 197 | case 4: | ||
| 198 | break; | ||
| 199 | case 5: | ||
| 200 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, true ); | ||
| 201 | break; | ||
| 202 | case 6: | ||
| 203 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( true, true, false, false ); | ||
| 204 | break; | ||
| 205 | case 7: | ||
| 206 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, true, false ); | ||
| 207 | break; | ||
| 208 | case 8: | ||
| 209 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( true, true, false, false ); | ||
| 210 | break; | ||
| 211 | case 9: | ||
| 212 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( true, false, false, true ); | ||
| 213 | break; | ||
| 214 | case 10: | ||
| 215 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, false ); | ||
| 216 | break; | ||
| 217 | case 11: | ||
| 218 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( true, false, false, true ); | ||
| 219 | break; | ||
| 220 | case 12: | ||
| 221 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, true, true, false ); | ||
| 222 | break; | ||
| 223 | case 13: | ||
| 224 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, false ); | ||
| 225 | break; | ||
| 226 | case 14: | ||
| 227 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, true, true, false ); | ||
| 228 | break; | ||
| 229 | case 15: | ||
| 230 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, false ); | ||
| 231 | break; | ||
| 232 | case 16: | ||
| 233 | break; | ||
| 234 | case 17: | ||
| 235 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, true, false ); | ||
| 236 | break; | ||
| 237 | case 18: | ||
| 238 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, true ); | ||
| 239 | break; | ||
| 240 | case 19: | ||
| 241 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, true, false ); | ||
| 242 | break; | ||
| 243 | case 20: | ||
| 244 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, true ); | ||
| 245 | break; | ||
| 246 | case 21: | ||
| 247 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, true, false ); | ||
| 248 | break; | ||
| 249 | case 22: | ||
| 250 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, true ); | ||
| 251 | break; | ||
| 252 | case 23: | ||
| 253 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( true, true, true, true ); | ||
| 254 | break; | ||
| 255 | case 24: | ||
| 256 | break; | ||
| 257 | case 25: | ||
| 258 | break; | ||
| 259 | case 26: | ||
| 260 | RobotFrame.main.list.getRobot( RobotFrame.this.getTitle() ).setPositions( false, false, false, false ); | ||
| 261 | break; | ||
| 262 | case 27: | ||
| 263 | JOptionPane.showMessageDialog( RobotFrame.this, "Cha fatica!", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE ); | ||
| 264 | JOptionPane.showMessageDialog( RobotFrame.this, RobotFrame.this.getTitle() + " è tornato alla posizione di partenza", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE ); | ||
| 265 | break; | ||
| 266 | default: | ||
| 267 | timer.stop(); | ||
| 268 | break; | ||
| 269 | } | ||
| 270 | RobotFrame.robotPanel.setImages(); | ||
| 271 | RobotFrame.robotPanel.repaint(); | ||
| 272 | RobotFrame.this.repaint(); | ||
| 273 | } | ||
| 274 | } | ||
| 275 | ); | ||
| 276 | timer.start(); | ||
| 277 | } | ||
| 278 | if ( e.getSource() == esplodi ) { | ||
| 279 | String aux = this.getTitle(); | ||
| 280 | main.list.deleteRobot( this.getTitle() ); | ||
| 281 | this.dispose(); | ||
| 282 | ImageIcon boom = new ImageIcon( ClassLoader.getSystemResource( "img/boom.png" ) ); | ||
| 283 | JOptionPane.showMessageDialog( null, "", "Robottino v4.1", JOptionPane.PLAIN_MESSAGE, boom ); | ||
| 284 | JOptionPane.showMessageDialog( null, aux + " si è autodistrutto!", "Robottino v4.1", JOptionPane.WARNING_MESSAGE ); | ||
| 285 | } | ||
| 286 | if ( e.getSource() == informazioni ) { | ||
| 287 | String aux = this.getTitle() + ":\n\n"; | ||
| 288 | if ( main.list.getRobot( RobotFrame.this.getTitle() ).rightArm ) | ||
| 289 | aux += "Braccio destro: alzato\n"; | ||
| 290 | else | ||
| 291 | aux += "Braccio destro: abbassato\n"; | ||
| 292 | if ( main.list.getRobot( RobotFrame.this.getTitle() ).leftArm ) | ||
| 293 | aux += "Braccio sinistro: alzato\n"; | ||
| 294 | else | ||
| 295 | aux += "Braccio sinistro: abbassato\n"; | ||
| 296 | if ( main.list.getRobot( RobotFrame.this.getTitle() ).rightLeg ) | ||
| 297 | aux += "Gamba destra: alzata\n"; | ||
| 298 | else | ||
| 299 | aux += "Gamba destra: abbassata\n"; | ||
| 300 | if ( main.list.getRobot( RobotFrame.this.getTitle() ).leftLeg ) | ||
| 301 | aux += "Gamba sinistra: alzata\n"; | ||
| 302 | else | ||
| 303 | aux += "Gamba sinistra: abbassata\n"; | ||
| 304 | JOptionPane.showMessageDialog( this, aux, "Robottino - v4.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 305 | } | ||
| 306 | try { | ||
| 307 | robotPanel.setImages(); | ||
| 308 | robotPanel.repaint(); | ||
| 309 | repaint(); | ||
| 310 | } catch ( NullPointerException n ) { } | ||
| 311 | } | ||
| 312 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.1/src/RobotPanel.java b/robottino/all_versions/v4.1/src/RobotPanel.java new file mode 100755 index 0000000..b66d90e --- /dev/null +++ b/robottino/all_versions/v4.1/src/RobotPanel.java | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class RobotPanel extends JPanel { | ||
| 26 | public static String nomeRobot; | ||
| 27 | public static Main main; | ||
| 28 | public static ImageIcon ra, la, rl, ll, body; | ||
| 29 | public static int rax, ray, lax, lay, rlx, rly, llx, lly; | ||
| 30 | RobotPanel( String nomeRobot ) { | ||
| 31 | this.nomeRobot = nomeRobot; | ||
| 32 | rax = 66; | ||
| 33 | ray = 248; | ||
| 34 | lax = 225; | ||
| 35 | lay = 242; | ||
| 36 | rlx = 84; | ||
| 37 | rly = 367; | ||
| 38 | llx = 148; | ||
| 39 | lly = 367; | ||
| 40 | body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); | ||
| 41 | ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 42 | la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 43 | rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 44 | ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 45 | } | ||
| 46 | public void paint ( Graphics g ) { | ||
| 47 | super.paint( g ); | ||
| 48 | body.paintIcon( this, g, 100, 60 ); | ||
| 49 | ra.paintIcon( this, g, this.rax, this.ray ); | ||
| 50 | la.paintIcon( this, g, this.lax, this.lay ); | ||
| 51 | rl.paintIcon( this, g, this.rlx, this.rly ); | ||
| 52 | ll.paintIcon( this, g, this.llx, this.lly ); | ||
| 53 | } | ||
| 54 | public void setImages() { | ||
| 55 | if ( main.list.getRobot( nomeRobot ).rightArm ) { | ||
| 56 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raon.gif" ) ); | ||
| 57 | this.rax = 68; | ||
| 58 | this.ray = 128; | ||
| 59 | } | ||
| 60 | else { | ||
| 61 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 62 | this.rax = 66; | ||
| 63 | this.ray = 248; | ||
| 64 | } | ||
| 65 | if ( main.list.getRobot( nomeRobot ).leftArm ) { | ||
| 66 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laon.gif" ) ); | ||
| 67 | this.lax = 224; | ||
| 68 | this.lay = 118; | ||
| 69 | } | ||
| 70 | else { | ||
| 71 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 72 | this.lax = 225; | ||
| 73 | this.lay = 242; | ||
| 74 | } | ||
| 75 | if ( main.list.getRobot( nomeRobot ).rightLeg ) { | ||
| 76 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rlon.gif" ) ); | ||
| 77 | this.rlx = 84; | ||
| 78 | this.rly = 356; | ||
| 79 | } | ||
| 80 | else { | ||
| 81 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 82 | this.rlx = 84; | ||
| 83 | this.rly = 367; | ||
| 84 | } | ||
| 85 | if ( main.list.getRobot( nomeRobot ).leftLeg ) { | ||
| 86 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/llon.gif" ) ); | ||
| 87 | this.llx = 140; | ||
| 88 | this.lly = 363; | ||
| 89 | } | ||
| 90 | else { | ||
| 91 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 92 | this.llx = 148; | ||
| 93 | this.lly = 367; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.1/src/img/birra1.jpg b/robottino/all_versions/v4.1/src/img/birra1.jpg new file mode 100755 index 0000000..6cbf8a8 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/birra1.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/birra2.jpg b/robottino/all_versions/v4.1/src/img/birra2.jpg new file mode 100755 index 0000000..3b3caae --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/birra2.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/birra3.jpg b/robottino/all_versions/v4.1/src/img/birra3.jpg new file mode 100755 index 0000000..9bc6971 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/birra3.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/birra4.jpg b/robottino/all_versions/v4.1/src/img/birra4.jpg new file mode 100755 index 0000000..970f2ff --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/birra4.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/birra5.gif b/robottino/all_versions/v4.1/src/img/birra5.gif new file mode 100755 index 0000000..6318d90 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/birra5.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/boom.png b/robottino/all_versions/v4.1/src/img/boom.png new file mode 100755 index 0000000..59b507a --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/boom.png | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/laoff.gif b/robottino/all_versions/v4.1/src/img/laoff.gif new file mode 100755 index 0000000..49d9db0 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/laoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/laon.gif b/robottino/all_versions/v4.1/src/img/laon.gif new file mode 100755 index 0000000..1880677 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/laon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/lloff.gif b/robottino/all_versions/v4.1/src/img/lloff.gif new file mode 100755 index 0000000..3db1ceb --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/lloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/llon.gif b/robottino/all_versions/v4.1/src/img/llon.gif new file mode 100755 index 0000000..ab1ff75 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/llon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/raoff.gif b/robottino/all_versions/v4.1/src/img/raoff.gif new file mode 100755 index 0000000..88aabc4 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/raoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/raon.gif b/robottino/all_versions/v4.1/src/img/raon.gif new file mode 100755 index 0000000..46190a8 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/raon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/rloff.gif b/robottino/all_versions/v4.1/src/img/rloff.gif new file mode 100755 index 0000000..04bda22 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/rloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/rlon.gif b/robottino/all_versions/v4.1/src/img/rlon.gif new file mode 100755 index 0000000..447464b --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/rlon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.1/src/img/robot.gif b/robottino/all_versions/v4.1/src/img/robot.gif new file mode 100755 index 0000000..db87686 --- /dev/null +++ b/robottino/all_versions/v4.1/src/img/robot.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/Robottino.jar b/robottino/all_versions/v4.2/Robottino.jar new file mode 100755 index 0000000..a3dc9e7 --- /dev/null +++ b/robottino/all_versions/v4.2/Robottino.jar | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/license.txt b/robottino/all_versions/v4.2/license.txt new file mode 100755 index 0000000..3912109 --- /dev/null +++ b/robottino/all_versions/v4.2/license.txt | |||
| @@ -0,0 +1,340 @@ | |||
| 1 | GNU GENERAL PUBLIC LICENSE | ||
| 2 | Version 2, June 1991 | ||
| 3 | |||
| 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. | ||
| 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 6 | Everyone is permitted to copy and distribute verbatim copies | ||
| 7 | of this license document, but changing it is not allowed. | ||
| 8 | |||
| 9 | Preamble | ||
| 10 | |||
| 11 | The licenses for most software are designed to take away your | ||
| 12 | freedom to share and change it. By contrast, the GNU General Public | ||
| 13 | License is intended to guarantee your freedom to share and change free | ||
| 14 | software--to make sure the software is free for all its users. This | ||
| 15 | General Public License applies to most of the Free Software | ||
| 16 | Foundation's software and to any other program whose authors commit to | ||
| 17 | using it. (Some other Free Software Foundation software is covered by | ||
| 18 | the GNU Library General Public License instead.) You can apply it to | ||
| 19 | your programs, too. | ||
| 20 | |||
| 21 | When we speak of free software, we are referring to freedom, not | ||
| 22 | price. Our General Public Licenses are designed to make sure that you | ||
| 23 | have the freedom to distribute copies of free software (and charge for | ||
| 24 | this service if you wish), that you receive source code or can get it | ||
| 25 | if you want it, that you can change the software or use pieces of it | ||
| 26 | in new free programs; and that you know you can do these things. | ||
| 27 | |||
| 28 | To protect your rights, we need to make restrictions that forbid | ||
| 29 | anyone to deny you these rights or to ask you to surrender the rights. | ||
| 30 | These restrictions translate to certain responsibilities for you if you | ||
| 31 | distribute copies of the software, or if you modify it. | ||
| 32 | |||
| 33 | For example, if you distribute copies of such a program, whether | ||
| 34 | gratis or for a fee, you must give the recipients all the rights that | ||
| 35 | you have. You must make sure that they, too, receive or can get the | ||
| 36 | source code. And you must show them these terms so they know their | ||
| 37 | rights. | ||
| 38 | |||
| 39 | We protect your rights with two steps: (1) copyright the software, and | ||
| 40 | (2) offer you this license which gives you legal permission to copy, | ||
| 41 | distribute and/or modify the software. | ||
| 42 | |||
| 43 | Also, for each author's protection and ours, we want to make certain | ||
| 44 | that everyone understands that there is no warranty for this free | ||
| 45 | software. If the software is modified by someone else and passed on, we | ||
| 46 | want its recipients to know that what they have is not the original, so | ||
| 47 | that any problems introduced by others will not reflect on the original | ||
| 48 | authors' reputations. | ||
| 49 | |||
| 50 | Finally, any free program is threatened constantly by software | ||
| 51 | patents. We wish to avoid the danger that redistributors of a free | ||
| 52 | program will individually obtain patent licenses, in effect making the | ||
| 53 | program proprietary. To prevent this, we have made it clear that any | ||
| 54 | patent must be licensed for everyone's free use or not licensed at all. | ||
| 55 | |||
| 56 | The precise terms and conditions for copying, distribution and | ||
| 57 | modification follow. | ||
| 58 | |||
| 59 | GNU GENERAL PUBLIC LICENSE | ||
| 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
| 61 | |||
| 62 | 0. This License applies to any program or other work which contains | ||
| 63 | a notice placed by the copyright holder saying it may be distributed | ||
| 64 | under the terms of this General Public License. The "Program", below, | ||
| 65 | refers to any such program or work, and a "work based on the Program" | ||
| 66 | means either the Program or any derivative work under copyright law: | ||
| 67 | that is to say, a work containing the Program or a portion of it, | ||
| 68 | either verbatim or with modifications and/or translated into another | ||
| 69 | language. (Hereinafter, translation is included without limitation in | ||
| 70 | the term "modification".) Each licensee is addressed as "you". | ||
| 71 | |||
| 72 | Activities other than copying, distribution and modification are not | ||
| 73 | covered by this License; they are outside its scope. The act of | ||
| 74 | running the Program is not restricted, and the output from the Program | ||
| 75 | is covered only if its contents constitute a work based on the | ||
| 76 | Program (independent of having been made by running the Program). | ||
| 77 | Whether that is true depends on what the Program does. | ||
| 78 | |||
| 79 | 1. You may copy and distribute verbatim copies of the Program's | ||
| 80 | source code as you receive it, in any medium, provided that you | ||
| 81 | conspicuously and appropriately publish on each copy an appropriate | ||
| 82 | copyright notice and disclaimer of warranty; keep intact all the | ||
| 83 | notices that refer to this License and to the absence of any warranty; | ||
| 84 | and give any other recipients of the Program a copy of this License | ||
| 85 | along with the Program. | ||
| 86 | |||
| 87 | You may charge a fee for the physical act of transferring a copy, and | ||
| 88 | you may at your option offer warranty protection in exchange for a fee. | ||
| 89 | |||
| 90 | 2. You may modify your copy or copies of the Program or any portion | ||
| 91 | of it, thus forming a work based on the Program, and copy and | ||
| 92 | distribute such modifications or work under the terms of Section 1 | ||
| 93 | above, provided that you also meet all of these conditions: | ||
| 94 | |||
| 95 | a) You must cause the modified files to carry prominent notices | ||
| 96 | stating that you changed the files and the date of any change. | ||
| 97 | |||
| 98 | b) You must cause any work that you distribute or publish, that in | ||
| 99 | whole or in part contains or is derived from the Program or any | ||
| 100 | part thereof, to be licensed as a whole at no charge to all third | ||
| 101 | parties under the terms of this License. | ||
| 102 | |||
| 103 | c) If the modified program normally reads commands interactively | ||
| 104 | when run, you must cause it, when started running for such | ||
| 105 | interactive use in the most ordinary way, to print or display an | ||
| 106 | announcement including an appropriate copyright notice and a | ||
| 107 | notice that there is no warranty (or else, saying that you provide | ||
| 108 | a warranty) and that users may redistribute the program under | ||
| 109 | these conditions, and telling the user how to view a copy of this | ||
| 110 | License. (Exception: if the Program itself is interactive but | ||
| 111 | does not normally print such an announcement, your work based on | ||
| 112 | the Program is not required to print an announcement.) | ||
| 113 | |||
| 114 | These requirements apply to the modified work as a whole. If | ||
| 115 | identifiable sections of that work are not derived from the Program, | ||
| 116 | and can be reasonably considered independent and separate works in | ||
| 117 | themselves, then this License, and its terms, do not apply to those | ||
| 118 | sections when you distribute them as separate works. But when you | ||
| 119 | distribute the same sections as part of a whole which is a work based | ||
| 120 | on the Program, the distribution of the whole must be on the terms of | ||
| 121 | this License, whose permissions for other licensees extend to the | ||
| 122 | entire whole, and thus to each and every part regardless of who wrote it. | ||
| 123 | |||
| 124 | Thus, it is not the intent of this section to claim rights or contest | ||
| 125 | your rights to work written entirely by you; rather, the intent is to | ||
| 126 | exercise the right to control the distribution of derivative or | ||
| 127 | collective works based on the Program. | ||
| 128 | |||
| 129 | In addition, mere aggregation of another work not based on the Program | ||
| 130 | with the Program (or with a work based on the Program) on a volume of | ||
| 131 | a storage or distribution medium does not bring the other work under | ||
| 132 | the scope of this License. | ||
| 133 | |||
| 134 | 3. You may copy and distribute the Program (or a work based on it, | ||
| 135 | under Section 2) in object code or executable form under the terms of | ||
| 136 | Sections 1 and 2 above provided that you also do one of the following: | ||
| 137 | |||
| 138 | a) Accompany it with the complete corresponding machine-readable | ||
| 139 | source code, which must be distributed under the terms of Sections | ||
| 140 | 1 and 2 above on a medium customarily used for software interchange; or, | ||
| 141 | |||
| 142 | b) Accompany it with a written offer, valid for at least three | ||
| 143 | years, to give any third party, for a charge no more than your | ||
| 144 | cost of physically performing source distribution, a complete | ||
| 145 | machine-readable copy of the corresponding source code, to be | ||
| 146 | distributed under the terms of Sections 1 and 2 above on a medium | ||
| 147 | customarily used for software interchange; or, | ||
| 148 | |||
| 149 | c) Accompany it with the information you received as to the offer | ||
| 150 | to distribute corresponding source code. (This alternative is | ||
| 151 | allowed only for noncommercial distribution and only if you | ||
| 152 | received the program in object code or executable form with such | ||
| 153 | an offer, in accord with Subsection b above.) | ||
| 154 | |||
| 155 | The source code for a work means the preferred form of the work for | ||
| 156 | making modifications to it. For an executable work, complete source | ||
| 157 | code means all the source code for all modules it contains, plus any | ||
| 158 | associated interface definition files, plus the scripts used to | ||
| 159 | control compilation and installation of the executable. However, as a | ||
| 160 | special exception, the source code distributed need not include | ||
| 161 | anything that is normally distributed (in either source or binary | ||
| 162 | form) with the major components (compiler, kernel, and so on) of the | ||
| 163 | operating system on which the executable runs, unless that component | ||
| 164 | itself accompanies the executable. | ||
| 165 | |||
| 166 | If distribution of executable or object code is made by offering | ||
| 167 | access to copy from a designated place, then offering equivalent | ||
| 168 | access to copy the source code from the same place counts as | ||
| 169 | distribution of the source code, even though third parties are not | ||
| 170 | compelled to copy the source along with the object code. | ||
| 171 | |||
| 172 | 4. You may not copy, modify, sublicense, or distribute the Program | ||
| 173 | except as expressly provided under this License. Any attempt | ||
| 174 | otherwise to copy, modify, sublicense or distribute the Program is | ||
| 175 | void, and will automatically terminate your rights under this License. | ||
| 176 | However, parties who have received copies, or rights, from you under | ||
| 177 | this License will not have their licenses terminated so long as such | ||
| 178 | parties remain in full compliance. | ||
| 179 | |||
| 180 | 5. You are not required to accept this License, since you have not | ||
| 181 | signed it. However, nothing else grants you permission to modify or | ||
| 182 | distribute the Program or its derivative works. These actions are | ||
| 183 | prohibited by law if you do not accept this License. Therefore, by | ||
| 184 | modifying or distributing the Program (or any work based on the | ||
| 185 | Program), you indicate your acceptance of this License to do so, and | ||
| 186 | all its terms and conditions for copying, distributing or modifying | ||
| 187 | the Program or works based on it. | ||
| 188 | |||
| 189 | 6. Each time you redistribute the Program (or any work based on the | ||
| 190 | Program), the recipient automatically receives a license from the | ||
| 191 | original licensor to copy, distribute or modify the Program subject to | ||
| 192 | these terms and conditions. You may not impose any further | ||
| 193 | restrictions on the recipients' exercise of the rights granted herein. | ||
| 194 | You are not responsible for enforcing compliance by third parties to | ||
| 195 | this License. | ||
| 196 | |||
| 197 | 7. If, as a consequence of a court judgment or allegation of patent | ||
| 198 | infringement or for any other reason (not limited to patent issues), | ||
| 199 | conditions are imposed on you (whether by court order, agreement or | ||
| 200 | otherwise) that contradict the conditions of this License, they do not | ||
| 201 | excuse you from the conditions of this License. If you cannot | ||
| 202 | distribute so as to satisfy simultaneously your obligations under this | ||
| 203 | License and any other pertinent obligations, then as a consequence you | ||
| 204 | may not distribute the Program at all. For example, if a patent | ||
| 205 | license would not permit royalty-free redistribution of the Program by | ||
| 206 | all those who receive copies directly or indirectly through you, then | ||
| 207 | the only way you could satisfy both it and this License would be to | ||
| 208 | refrain entirely from distribution of the Program. | ||
| 209 | |||
| 210 | If any portion of this section is held invalid or unenforceable under | ||
| 211 | any particular circumstance, the balance of the section is intended to | ||
| 212 | apply and the section as a whole is intended to apply in other | ||
| 213 | circumstances. | ||
| 214 | |||
| 215 | It is not the purpose of this section to induce you to infringe any | ||
| 216 | patents or other property right claims or to contest validity of any | ||
| 217 | such claims; this section has the sole purpose of protecting the | ||
| 218 | integrity of the free software distribution system, which is | ||
| 219 | implemented by public license practices. Many people have made | ||
| 220 | generous contributions to the wide range of software distributed | ||
| 221 | through that system in reliance on consistent application of that | ||
| 222 | system; it is up to the author/donor to decide if he or she is willing | ||
| 223 | to distribute software through any other system and a licensee cannot | ||
| 224 | impose that choice. | ||
| 225 | |||
| 226 | This section is intended to make thoroughly clear what is believed to | ||
| 227 | be a consequence of the rest of this License. | ||
| 228 | |||
| 229 | 8. If the distribution and/or use of the Program is restricted in | ||
| 230 | certain countries either by patents or by copyrighted interfaces, the | ||
| 231 | original copyright holder who places the Program under this License | ||
| 232 | may add an explicit geographical distribution limitation excluding | ||
| 233 | those countries, so that distribution is permitted only in or among | ||
| 234 | countries not thus excluded. In such case, this License incorporates | ||
| 235 | the limitation as if written in the body of this License. | ||
| 236 | |||
| 237 | 9. The Free Software Foundation may publish revised and/or new versions | ||
| 238 | of the General Public License from time to time. Such new versions will | ||
| 239 | be similar in spirit to the present version, but may differ in detail to | ||
| 240 | address new problems or concerns. | ||
| 241 | |||
| 242 | Each version is given a distinguishing version number. If the Program | ||
| 243 | specifies a version number of this License which applies to it and "any | ||
| 244 | later version", you have the option of following the terms and conditions | ||
| 245 | either of that version or of any later version published by the Free | ||
| 246 | Software Foundation. If the Program does not specify a version number of | ||
| 247 | this License, you may choose any version ever published by the Free Software | ||
| 248 | Foundation. | ||
| 249 | |||
| 250 | 10. If you wish to incorporate parts of the Program into other free | ||
| 251 | programs whose distribution conditions are different, write to the author | ||
| 252 | to ask for permission. For software which is copyrighted by the Free | ||
| 253 | Software Foundation, write to the Free Software Foundation; we sometimes | ||
| 254 | make exceptions for this. Our decision will be guided by the two goals | ||
| 255 | of preserving the free status of all derivatives of our free software and | ||
| 256 | of promoting the sharing and reuse of software generally. | ||
| 257 | |||
| 258 | NO WARRANTY | ||
| 259 | |||
| 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | ||
| 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | ||
| 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | ||
| 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | ||
| 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | ||
| 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | ||
| 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | ||
| 268 | REPAIR OR CORRECTION. | ||
| 269 | |||
| 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | ||
| 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | ||
| 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | ||
| 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | ||
| 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | ||
| 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | ||
| 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | ||
| 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | ||
| 278 | POSSIBILITY OF SUCH DAMAGES. | ||
| 279 | |||
| 280 | END OF TERMS AND CONDITIONS | ||
| 281 | |||
| 282 | How to Apply These Terms to Your New Programs | ||
| 283 | |||
| 284 | If you develop a new program, and you want it to be of the greatest | ||
| 285 | possible use to the public, the best way to achieve this is to make it | ||
| 286 | free software which everyone can redistribute and change under these terms. | ||
| 287 | |||
| 288 | To do so, attach the following notices to the program. It is safest | ||
| 289 | to attach them to the start of each source file to most effectively | ||
| 290 | convey the exclusion of warranty; and each file should have at least | ||
| 291 | the "copyright" line and a pointer to where the full notice is found. | ||
| 292 | |||
| 293 | <one line to give the program's name and a brief idea of what it does.> | ||
| 294 | Copyright (C) <year> <name of author> | ||
| 295 | |||
| 296 | This program is free software; you can redistribute it and/or modify | ||
| 297 | it under the terms of the GNU General Public License as published by | ||
| 298 | the Free Software Foundation; either version 2 of the License, or | ||
| 299 | (at your option) any later version. | ||
| 300 | |||
| 301 | This program is distributed in the hope that it will be useful, | ||
| 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 304 | GNU General Public License for more details. | ||
| 305 | |||
| 306 | You should have received a copy of the GNU General Public License | ||
| 307 | along with this program; if not, write to the Free Software | ||
| 308 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 309 | |||
| 310 | |||
| 311 | Also add information on how to contact you by electronic and paper mail. | ||
| 312 | |||
| 313 | If the program is interactive, make it output a short notice like this | ||
| 314 | when it starts in an interactive mode: | ||
| 315 | |||
| 316 | Gnomovision version 69, Copyright (C) year name of author | ||
| 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | ||
| 318 | This is free software, and you are welcome to redistribute it | ||
| 319 | under certain conditions; type `show c' for details. | ||
| 320 | |||
| 321 | The hypothetical commands `show w' and `show c' should show the appropriate | ||
| 322 | parts of the General Public License. Of course, the commands you use may | ||
| 323 | be called something other than `show w' and `show c'; they could even be | ||
| 324 | mouse-clicks or menu items--whatever suits your program. | ||
| 325 | |||
| 326 | You should also get your employer (if you work as a programmer) or your | ||
| 327 | school, if any, to sign a "copyright disclaimer" for the program, if | ||
| 328 | necessary. Here is a sample; alter the names: | ||
| 329 | |||
| 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program | ||
| 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. | ||
| 332 | |||
| 333 | <signature of Ty Coon>, 1 April 1989 | ||
| 334 | Ty Coon, President of Vice | ||
| 335 | |||
| 336 | This General Public License does not permit incorporating your program into | ||
| 337 | proprietary programs. If your program is a subroutine library, you may | ||
| 338 | consider it more useful to permit linking proprietary applications with the | ||
| 339 | library. If this is what you want to do, use the GNU Library General | ||
| 340 | Public License instead of this License. | ||
diff --git a/robottino/all_versions/v4.2/src/Frame.java b/robottino/all_versions/v4.2/src/Frame.java new file mode 100755 index 0000000..6015c41 --- /dev/null +++ b/robottino/all_versions/v4.2/src/Frame.java | |||
| @@ -0,0 +1,314 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | import java.awt.event.*; | ||
| 25 | |||
| 26 | public class Frame extends JFrame implements ActionListener { | ||
| 27 | public static int i; | ||
| 28 | public static Main main; | ||
| 29 | public static RobotPanel robotPanel; | ||
| 30 | public static JLabel label; | ||
| 31 | public static Timer timer; | ||
| 32 | public static JMenuBar barraMenu; | ||
| 33 | public static JMenu file, modifica, azioni, info, raMenu, laMenu, rlMenu, llMenu; | ||
| 34 | public static JMenuItem raonMenuItem, raoffMenuItem, rachangeMenuItem, laonMenuItem, laoffMenuItem, lachangeMenuItem; | ||
| 35 | public static JMenuItem rlonMenuItem, rloffMenuItem, rlchangeMenuItem, llonMenuItem, lloffMenuItem, llchangeMenuItem; | ||
| 36 | public static JMenuItem rinomina, birra, balla, esplodi, informazioni, esci; | ||
| 37 | public Frame() { | ||
| 38 | super( "Robottino versione 4.2" ); | ||
| 39 | i = 0; | ||
| 40 | main = new Main(); | ||
| 41 | robotPanel = new RobotPanel(); | ||
| 42 | label = new JLabel( "Robot: " + main.robot.getName() ); | ||
| 43 | label.setFont( new Font( "Monospace", 0, 30 ) ); | ||
| 44 | barraMenu = new JMenuBar(); | ||
| 45 | rinomina = new JMenuItem( "Cambia nome" ); | ||
| 46 | birra = new JMenuItem( "Birra" ); | ||
| 47 | balla = new JMenuItem( "Balla" ); | ||
| 48 | esplodi = new JMenuItem( "Esplodi" ); | ||
| 49 | informazioni = new JMenuItem( "Informazioni" ); | ||
| 50 | esci = new JMenuItem( "Esci" ); | ||
| 51 | raonMenuItem = new JMenuItem( "Alza" ); | ||
| 52 | laonMenuItem = new JMenuItem( "Alza" ); | ||
| 53 | rlonMenuItem = new JMenuItem( "Alza" ); | ||
| 54 | llonMenuItem = new JMenuItem( "Alza" ); | ||
| 55 | raoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 56 | laoffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 57 | rloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 58 | lloffMenuItem = new JMenuItem( "Abbassa" ); | ||
| 59 | rachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 60 | lachangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 61 | rlchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 62 | llchangeMenuItem = new JMenuItem( "Cambia posizione" ); | ||
| 63 | esci.addActionListener( this ); | ||
| 64 | rinomina.addActionListener( this ); | ||
| 65 | birra.addActionListener( this ); | ||
| 66 | balla.addActionListener( this ); | ||
| 67 | esplodi.addActionListener( this ); | ||
| 68 | informazioni.addActionListener( this ); | ||
| 69 | raonMenuItem.addActionListener( this ); | ||
| 70 | raoffMenuItem.addActionListener( this ); | ||
| 71 | rachangeMenuItem.addActionListener( this ); | ||
| 72 | laonMenuItem.addActionListener( this ); | ||
| 73 | laoffMenuItem.addActionListener( this ); | ||
| 74 | lachangeMenuItem.addActionListener( this ); | ||
| 75 | rlonMenuItem.addActionListener( this ); | ||
| 76 | rloffMenuItem.addActionListener( this ); | ||
| 77 | rlchangeMenuItem.addActionListener( this ); | ||
| 78 | llonMenuItem.addActionListener( this ); | ||
| 79 | lloffMenuItem.addActionListener( this ); | ||
| 80 | llchangeMenuItem.addActionListener( this ); | ||
| 81 | raMenu = new JMenu( "Braccio destro" ); | ||
| 82 | raMenu.add( raonMenuItem ); | ||
| 83 | raMenu.add( raoffMenuItem ); | ||
| 84 | raMenu.add( rachangeMenuItem ); | ||
| 85 | laMenu = new JMenu( "Braccio sinistro" ); | ||
| 86 | laMenu.add( laonMenuItem ); | ||
| 87 | laMenu.add( laoffMenuItem ); | ||
| 88 | laMenu.add( lachangeMenuItem ); | ||
| 89 | rlMenu = new JMenu( "Gamba destra" ); | ||
| 90 | rlMenu.add( rlonMenuItem ); | ||
| 91 | rlMenu.add( rloffMenuItem ); | ||
| 92 | rlMenu.add( rlchangeMenuItem ); | ||
| 93 | llMenu = new JMenu( "Gamba sinistra" ); | ||
| 94 | llMenu.add( llonMenuItem ); | ||
| 95 | llMenu.add( lloffMenuItem ); | ||
| 96 | llMenu.add( llchangeMenuItem ); | ||
| 97 | modifica = new JMenu( "Modifica" ); | ||
| 98 | modifica.add( raMenu ); | ||
| 99 | modifica.add( laMenu ); | ||
| 100 | modifica.add( rlMenu ); | ||
| 101 | modifica.add( llMenu ); | ||
| 102 | file = new JMenu( "File" ); | ||
| 103 | file.add( rinomina ); | ||
| 104 | file.add( esci ); | ||
| 105 | azioni = new JMenu( "Azioni" ); | ||
| 106 | azioni.add( birra ); | ||
| 107 | azioni.add( balla ); | ||
| 108 | azioni.add( esplodi ); | ||
| 109 | info = new JMenu( "?" ); | ||
| 110 | info.add( informazioni ); | ||
| 111 | barraMenu.add( file ); | ||
| 112 | barraMenu.add( modifica ); | ||
| 113 | barraMenu.add( azioni ); | ||
| 114 | barraMenu.add( info ); | ||
| 115 | setJMenuBar( barraMenu ); | ||
| 116 | add( robotPanel, BorderLayout.CENTER ); | ||
| 117 | add( label, BorderLayout.SOUTH ); | ||
| 118 | addWindowListener( | ||
| 119 | new WindowAdapter() { | ||
| 120 | public void windowClosing( WindowEvent e ) { | ||
| 121 | int selezione = JOptionPane.showOptionDialog( Frame.this, "Vuoi davvero uscire?", "Robottino v4.2", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 122 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 123 | System.exit( 0 ); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | ); | ||
| 127 | } | ||
| 128 | public void actionPerformed( ActionEvent e ) { | ||
| 129 | if ( e.getSource() == esci ) { | ||
| 130 | int selezione = JOptionPane.showOptionDialog( this, "Vuoi davvero uscire?", "Robottino v4.2", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 131 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 132 | System.exit( 0 ); | ||
| 133 | } | ||
| 134 | else if ( e.getSource() == rinomina ) { | ||
| 135 | String newName = main.robot.getName(); | ||
| 136 | newName = JOptionPane.showInputDialog( this, "Inserire il nuovo nome per il robottino:", newName ); | ||
| 137 | if ( newName != null ) { | ||
| 138 | main.robot.setName( newName ); | ||
| 139 | label .setText( "Robot: " + main.robot.getName() ); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | else if ( e.getSource() == raonMenuItem ) | ||
| 143 | main.robot.setRA( true ); | ||
| 144 | else if ( e.getSource() == raoffMenuItem ) | ||
| 145 | main.robot.setRA( false ); | ||
| 146 | else if ( e.getSource() == rachangeMenuItem ) | ||
| 147 | main.robot.setRA( !main.robot.rightArm ); | ||
| 148 | else if ( e.getSource() == laonMenuItem ) | ||
| 149 | main.robot.setLA( true ); | ||
| 150 | else if ( e.getSource() == laoffMenuItem ) | ||
| 151 | main.robot.setLA( false ); | ||
| 152 | else if ( e.getSource() == lachangeMenuItem ) | ||
| 153 | main.robot.setLA( !main.robot.leftArm ); | ||
| 154 | else if ( e.getSource() == rlonMenuItem ) | ||
| 155 | main.robot.setRL( true ); | ||
| 156 | else if ( e.getSource() == rloffMenuItem ) | ||
| 157 | main.robot.setRL( false ); | ||
| 158 | else if ( e.getSource() == rlchangeMenuItem ) | ||
| 159 | main.robot.setRL( !main.robot.rightLeg ); | ||
| 160 | else if ( e.getSource() == llonMenuItem ) | ||
| 161 | main.robot.setLL( true ); | ||
| 162 | else if ( e.getSource() == lloffMenuItem ) | ||
| 163 | main.robot.setLL( false ); | ||
| 164 | else if ( e.getSource() == llchangeMenuItem ) | ||
| 165 | main.robot.setLL( !main.robot.leftLeg ); | ||
| 166 | else if ( e.getSource() == birra ) { | ||
| 167 | ImageIcon birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra5.gif" ) ); | ||
| 168 | JOptionPane.showMessageDialog( this, "", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 169 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra1.jpg" ) ); | ||
| 170 | JOptionPane.showMessageDialog( this, "", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 171 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra2.jpg" ) ); | ||
| 172 | JOptionPane.showMessageDialog( this, "", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 173 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra3.jpg" ) ); | ||
| 174 | JOptionPane.showMessageDialog( this, "", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 175 | birra = new ImageIcon( ClassLoader.getSystemResource( "img/birra4.jpg" ) ); | ||
| 176 | JOptionPane.showMessageDialog( this, "", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE, birra ); | ||
| 177 | JOptionPane.showMessageDialog( this, "Che bevuta!", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE ); | ||
| 178 | JOptionPane.showMessageDialog( this, "Buuuuuuurp!", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE ); | ||
| 179 | robotPanel.body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); | ||
| 180 | } | ||
| 181 | if ( e.getSource() == esplodi ) { | ||
| 182 | String aux = main.robot.getName(); | ||
| 183 | main.robot.setPositions( false, false, false, false ); | ||
| 184 | main.robot.setName( "no-name" ); | ||
| 185 | label.setText( "Robot: " + main.robot.getName() ); | ||
| 186 | ImageIcon boom = new ImageIcon( ClassLoader.getSystemResource( "img/boom.png" ) ); | ||
| 187 | JOptionPane.showMessageDialog( this, "", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE, boom ); | ||
| 188 | JOptionPane.showMessageDialog( this, aux + " si è autodistrutto!", "Robottino v4.2", JOptionPane.WARNING_MESSAGE ); | ||
| 189 | JOptionPane.showMessageDialog( this, "È stato creato un nuovo robottino: " + main.robot.getName(), "Robottino v4.2", JOptionPane.INFORMATION_MESSAGE ); | ||
| 190 | } | ||
| 191 | if ( e.getSource() == informazioni ) { | ||
| 192 | String aux = main.robot.getName() + ":\n\n"; | ||
| 193 | if ( main.robot.rightArm ) | ||
| 194 | aux += "Braccio destro: alzato\n"; | ||
| 195 | else | ||
| 196 | aux += "Braccio destro: abbassato\n"; | ||
| 197 | if ( main.robot.leftArm ) | ||
| 198 | aux += "Braccio sinistro: alzato\n"; | ||
| 199 | else | ||
| 200 | aux += "Braccio sinistro: abbassato\n"; | ||
| 201 | if ( main.robot.rightLeg ) | ||
| 202 | aux += "Gamba destra: alzata\n"; | ||
| 203 | else | ||
| 204 | aux += "Gamba destra: abbassata\n"; | ||
| 205 | if ( main.robot.leftLeg ) | ||
| 206 | aux += "Gamba sinistra: alzata\n"; | ||
| 207 | else | ||
| 208 | aux += "Gamba sinistra: abbassata\n"; | ||
| 209 | JOptionPane.showMessageDialog( this, aux, "Robottino - v4.2", JOptionPane.INFORMATION_MESSAGE ); | ||
| 210 | } | ||
| 211 | else if ( e.getSource() == balla ) { | ||
| 212 | this.i = 0; | ||
| 213 | main.robot.setPositions( false, false, false, false ); | ||
| 214 | timer = new Timer( 250, | ||
| 215 | new ActionListener() { | ||
| 216 | public void actionPerformed( ActionEvent e ) { | ||
| 217 | Frame.this.i++; | ||
| 218 | switch( Frame.this.i ) { | ||
| 219 | case 1: | ||
| 220 | Frame.main.robot.setRA( true ); | ||
| 221 | break; | ||
| 222 | case 2: | ||
| 223 | break; | ||
| 224 | case 3: | ||
| 225 | Frame.main.robot.setLA( true ); | ||
| 226 | break; | ||
| 227 | case 4: | ||
| 228 | break; | ||
| 229 | case 5: | ||
| 230 | Frame.main.robot.setPositions( false, false, false, true ); | ||
| 231 | break; | ||
| 232 | case 6: | ||
| 233 | Frame.main.robot.setPositions( true, true, false, false ); | ||
| 234 | break; | ||
| 235 | case 7: | ||
| 236 | Frame.main.robot.setPositions( false, false, true, false ); | ||
| 237 | break; | ||
| 238 | case 8: | ||
| 239 | Frame.main.robot.setPositions( true, true, false, false ); | ||
| 240 | break; | ||
| 241 | case 9: | ||
| 242 | Frame.main.robot.setPositions( true, false, false, true ); | ||
| 243 | break; | ||
| 244 | case 10: | ||
| 245 | Frame.main.robot.setPositions( false, false, false, false ); | ||
| 246 | break; | ||
| 247 | case 11: | ||
| 248 | Frame.main.robot.setPositions( true, false, false, true ); | ||
| 249 | break; | ||
| 250 | case 12: | ||
| 251 | Frame.main.robot.setPositions( false, true, true, false ); | ||
| 252 | break; | ||
| 253 | case 13: | ||
| 254 | Frame.main.robot.setPositions( false, false, false, false ); | ||
| 255 | break; | ||
| 256 | case 14: | ||
| 257 | Frame.main.robot.setPositions( false, true, true, false ); | ||
| 258 | break; | ||
| 259 | case 15: | ||
| 260 | Frame.main.robot.setPositions( false, false, false, false ); | ||
| 261 | break; | ||
| 262 | case 16: | ||
| 263 | break; | ||
| 264 | case 17: | ||
| 265 | Frame.main.robot.setPositions( false, false, true, false ); | ||
| 266 | break; | ||
| 267 | case 18: | ||
| 268 | Frame.main.robot.setPositions( false, false, false, true ); | ||
| 269 | break; | ||
| 270 | case 19: | ||
| 271 | Frame.main.robot.setPositions( false, false, true, false ); | ||
| 272 | break; | ||
| 273 | case 20: | ||
| 274 | Frame.main.robot.setPositions( false, false, false, true ); | ||
| 275 | break; | ||
| 276 | case 21: | ||
| 277 | Frame.main.robot.setPositions( false, false, true, false ); | ||
| 278 | break; | ||
| 279 | case 22: | ||
| 280 | Frame.main.robot.setPositions( false, false, false, true ); | ||
| 281 | break; | ||
| 282 | case 23: | ||
| 283 | Frame.main.robot.setPositions( true, true, true, true ); | ||
| 284 | break; | ||
| 285 | case 24: | ||
| 286 | break; | ||
| 287 | case 25: | ||
| 288 | break; | ||
| 289 | case 26: | ||
| 290 | Frame.main.robot.setPositions( false, false, false, false ); | ||
| 291 | break; | ||
| 292 | case 27: | ||
| 293 | JOptionPane.showMessageDialog( Frame.this, "Cha fatica!", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE ); | ||
| 294 | JOptionPane.showMessageDialog( Frame.this, Frame.main.robot.getName() + " è tornato alla posizione di partenza", "Robottino v4.2", JOptionPane.PLAIN_MESSAGE ); | ||
| 295 | break; | ||
| 296 | default: | ||
| 297 | timer.stop(); | ||
| 298 | break; | ||
| 299 | } | ||
| 300 | Frame.this.robotPanel.setImages(); | ||
| 301 | Frame.this.robotPanel.repaint(); | ||
| 302 | Frame.this.repaint(); | ||
| 303 | } | ||
| 304 | } | ||
| 305 | ); | ||
| 306 | timer.start(); | ||
| 307 | } | ||
| 308 | try { | ||
| 309 | this.robotPanel.setImages(); | ||
| 310 | this.robotPanel.repaint(); | ||
| 311 | this.repaint(); | ||
| 312 | } catch ( NullPointerException n ) { } | ||
| 313 | } | ||
| 314 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.2/src/Main.java b/robottino/all_versions/v4.2/src/Main.java new file mode 100755 index 0000000..61eecc4 --- /dev/null +++ b/robottino/all_versions/v4.2/src/Main.java | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.JFrame; | ||
| 23 | |||
| 24 | public class Main { | ||
| 25 | public static Robot robot; | ||
| 26 | public static Frame frame; | ||
| 27 | public static void main ( String args[] ) { | ||
| 28 | robot = new Robot( "no-name" ); | ||
| 29 | frame = new Frame(); | ||
| 30 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 31 | frame.setSize( 350, 600 ); | ||
| 32 | frame.setVisible( true ); | ||
| 33 | } | ||
| 34 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.2/src/Robot.java b/robottino/all_versions/v4.2/src/Robot.java new file mode 100755 index 0000000..378f2db --- /dev/null +++ b/robottino/all_versions/v4.2/src/Robot.java | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | import java.awt.*; | ||
| 25 | |||
| 26 | public class Robot { | ||
| 27 | boolean leftArm, rightArm, leftLeg, rightLeg; | ||
| 28 | String nomeRobot; | ||
| 29 | Robot( String nome ) { | ||
| 30 | this.leftArm = false; | ||
| 31 | this.rightArm = false; | ||
| 32 | this.leftLeg = false; | ||
| 33 | this.rightLeg = false; | ||
| 34 | this.nomeRobot = nome; | ||
| 35 | } | ||
| 36 | void setLA( boolean la ) { | ||
| 37 | setPositions( la, this.rightArm, this.leftLeg, this.rightLeg ); | ||
| 38 | } | ||
| 39 | void setRA( boolean ra ) { | ||
| 40 | setPositions( this.leftArm, ra, this.leftLeg, this.rightLeg ); | ||
| 41 | } | ||
| 42 | void setLL( boolean ll ) { | ||
| 43 | setPositions( this.leftArm, this.rightArm, ll, this.rightLeg ); | ||
| 44 | } | ||
| 45 | void setRL( boolean rl ) { | ||
| 46 | setPositions( this.leftArm, this.rightArm, this.leftLeg, rl ); | ||
| 47 | } | ||
| 48 | void setPositions( boolean la, boolean ra, boolean ll, boolean rl ) { | ||
| 49 | this.leftArm = la; | ||
| 50 | this.rightArm = ra; | ||
| 51 | this.leftLeg = ll; | ||
| 52 | this.rightLeg = rl; | ||
| 53 | } | ||
| 54 | void setName( String nome ) { | ||
| 55 | nomeRobot = nome; | ||
| 56 | } | ||
| 57 | boolean getLA() { | ||
| 58 | return leftArm; | ||
| 59 | } | ||
| 60 | boolean getRA() { | ||
| 61 | return rightArm; | ||
| 62 | } | ||
| 63 | boolean getLL() { | ||
| 64 | return leftLeg; | ||
| 65 | } | ||
| 66 | boolean getRL() { | ||
| 67 | return rightLeg; | ||
| 68 | } | ||
| 69 | String getName() { | ||
| 70 | return nomeRobot; | ||
| 71 | } | ||
| 72 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.2/src/RobotPanel.java b/robottino/all_versions/v4.2/src/RobotPanel.java new file mode 100755 index 0000000..896723a --- /dev/null +++ b/robottino/all_versions/v4.2/src/RobotPanel.java | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class RobotPanel extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public static ImageIcon ra, la, rl, ll, body; | ||
| 28 | public static int rax, ray, lax, lay, rlx, rly, llx, lly; | ||
| 29 | RobotPanel() { | ||
| 30 | rax = 66; | ||
| 31 | ray = 248; | ||
| 32 | lax = 225; | ||
| 33 | lay = 242; | ||
| 34 | rlx = 84; | ||
| 35 | rly = 367; | ||
| 36 | llx = 148; | ||
| 37 | lly = 367; | ||
| 38 | body = new ImageIcon( ClassLoader.getSystemResource( "img/robot.gif" ) ); | ||
| 39 | ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 40 | la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 41 | rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 42 | ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 43 | } | ||
| 44 | public void paint ( Graphics g ) { | ||
| 45 | super.paint( g ); | ||
| 46 | body.paintIcon( this, g, 100, 60 ); | ||
| 47 | ra.paintIcon( this, g, this.rax, this.ray ); | ||
| 48 | la.paintIcon( this, g, this.lax, this.lay ); | ||
| 49 | rl.paintIcon( this, g, this.rlx, this.rly ); | ||
| 50 | ll.paintIcon( this, g, this.llx, this.lly ); | ||
| 51 | } | ||
| 52 | public void setImages() { | ||
| 53 | if ( main.robot.rightArm ) { | ||
| 54 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raon.gif" ) ); | ||
| 55 | this.rax = 68; | ||
| 56 | this.ray = 128; | ||
| 57 | } | ||
| 58 | else { | ||
| 59 | this.ra = new ImageIcon( ClassLoader.getSystemResource( "img/raoff.gif" ) ); | ||
| 60 | this.rax = 66; | ||
| 61 | this.ray = 248; | ||
| 62 | } | ||
| 63 | if ( main.robot.leftArm ) { | ||
| 64 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laon.gif" ) ); | ||
| 65 | this.lax = 224; | ||
| 66 | this.lay = 118; | ||
| 67 | } | ||
| 68 | else { | ||
| 69 | this.la = new ImageIcon( ClassLoader.getSystemResource( "img/laoff.gif" ) ); | ||
| 70 | this.lax = 225; | ||
| 71 | this.lay = 242; | ||
| 72 | } | ||
| 73 | if ( main.robot.rightLeg ) { | ||
| 74 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rlon.gif" ) ); | ||
| 75 | this.rlx = 84; | ||
| 76 | this.rly = 356; | ||
| 77 | } | ||
| 78 | else { | ||
| 79 | this.rl = new ImageIcon( ClassLoader.getSystemResource( "img/rloff.gif" ) ); | ||
| 80 | this.rlx = 84; | ||
| 81 | this.rly = 367; | ||
| 82 | } | ||
| 83 | if ( main.robot.leftLeg ) { | ||
| 84 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/llon.gif" ) ); | ||
| 85 | this.llx = 140; | ||
| 86 | this.lly = 363; | ||
| 87 | } | ||
| 88 | else { | ||
| 89 | this.ll = new ImageIcon( ClassLoader.getSystemResource( "img/lloff.gif" ) ); | ||
| 90 | this.llx = 148; | ||
| 91 | this.lly = 367; | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } \ No newline at end of file | ||
diff --git a/robottino/all_versions/v4.2/src/img/birra1.jpg b/robottino/all_versions/v4.2/src/img/birra1.jpg new file mode 100755 index 0000000..6cbf8a8 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/birra1.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/birra2.jpg b/robottino/all_versions/v4.2/src/img/birra2.jpg new file mode 100755 index 0000000..3b3caae --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/birra2.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/birra3.jpg b/robottino/all_versions/v4.2/src/img/birra3.jpg new file mode 100755 index 0000000..9bc6971 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/birra3.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/birra4.jpg b/robottino/all_versions/v4.2/src/img/birra4.jpg new file mode 100755 index 0000000..970f2ff --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/birra4.jpg | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/birra5.gif b/robottino/all_versions/v4.2/src/img/birra5.gif new file mode 100755 index 0000000..6318d90 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/birra5.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/boom.png b/robottino/all_versions/v4.2/src/img/boom.png new file mode 100755 index 0000000..59b507a --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/boom.png | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/laoff.gif b/robottino/all_versions/v4.2/src/img/laoff.gif new file mode 100755 index 0000000..49d9db0 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/laoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/laon.gif b/robottino/all_versions/v4.2/src/img/laon.gif new file mode 100755 index 0000000..1880677 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/laon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/lloff.gif b/robottino/all_versions/v4.2/src/img/lloff.gif new file mode 100755 index 0000000..3db1ceb --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/lloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/llon.gif b/robottino/all_versions/v4.2/src/img/llon.gif new file mode 100755 index 0000000..ab1ff75 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/llon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/raoff.gif b/robottino/all_versions/v4.2/src/img/raoff.gif new file mode 100755 index 0000000..88aabc4 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/raoff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/raon.gif b/robottino/all_versions/v4.2/src/img/raon.gif new file mode 100755 index 0000000..46190a8 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/raon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/rloff.gif b/robottino/all_versions/v4.2/src/img/rloff.gif new file mode 100755 index 0000000..04bda22 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/rloff.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/rlon.gif b/robottino/all_versions/v4.2/src/img/rlon.gif new file mode 100755 index 0000000..447464b --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/rlon.gif | |||
| Binary files differ | |||
diff --git a/robottino/all_versions/v4.2/src/img/robot.gif b/robottino/all_versions/v4.2/src/img/robot.gif new file mode 100755 index 0000000..db87686 --- /dev/null +++ b/robottino/all_versions/v4.2/src/img/robot.gif | |||
| Binary files differ | |||
