diff options
Diffstat (limited to 'robottino/all_versions/v2.1')
| -rwxr-xr-x | robottino/all_versions/v2.1/Esegui.bat | 2 | ||||
| -rwxr-xr-x | robottino/all_versions/v2.1/Esegui.sh | 2 | ||||
| -rwxr-xr-x | robottino/all_versions/v2.1/Readme.txt | 10 | ||||
| -rwxr-xr-x | robottino/all_versions/v2.1/bin/PartiDelRobot.class | bin | 0 -> 379 bytes | |||
| -rwxr-xr-x | robottino/all_versions/v2.1/bin/Robottino.class | bin | 0 -> 10163 bytes | |||
| -rwxr-xr-x | robottino/all_versions/v2.1/src/PartiDelRobot.java | 9 | ||||
| -rwxr-xr-x | robottino/all_versions/v2.1/src/Robottino.java | 258 |
7 files changed, 281 insertions, 0 deletions
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 | |||
