import java.util.Scanner; class Robottino extends PartiDelRobot { static PartiDelRobot pdr[][] = { { new PartiDelRobot (false, "il braccio sinistro alzato"), new PartiDelRobot (false, "il braccio destro alzato"), new PartiDelRobot (false, "la gamba sinistra alzata"), new PartiDelRobot (false, "la gamba destra alzata") } }; static String nomeRobot[] = { "" }; int robotIndex = 0; public static void main(String argv[]) { Scanner sc = new Scanner(System.in); String comando; Robottino robottino = new Robottino(); System.out.println ("**********************************************"); System.out.println ("**********************************************"); System.out.println ("*************Programma interattivo************"); System.out.println ("**********************************************"); System.out.println ("***Software realizzato da Sebastiano Tronto***"); System.out.println ("**********************************************"); System.out.println ("**********************************************"); System.out.println ("Questo programma simula un robot al quale ven-"); System.out.println ("gono assegnati ordini tramite comandi, simil-" ); System.out.println ("mente a quanto bisognava fare con i computer " ); System.out.println ("alcuni anni fa." ); System.out.println ("Dato che all'epoca i comandi che dovevano es-" ); System.out.println ("sere dati erano (e sono tutt'ora) in similin-" ); System.out.println ("glese, ho cercato di mantenerli tali." ); System.out.println ("Il programma non fa distinzioni tra lettere" ); System.out.println ("maiuscole o minuscole." ); System.out.println ("In questa versione non sono ancora disponibi-" ); System.out.println ("li immagini e/o effetti grafici." ); System.out.println ("" ); System.out.println ("Digita un comando e premi INVIO" ); System.out.println ("l = legenda comandi" ); System.out.println (""); do { comando = sc.nextLine(); System.out.println (""); System.out.println (robottino.Azioni(comando, nomeRobot, pdr)); System.out.println (""); } while ( !(comando.equalsIgnoreCase("exit")) ); } String Azioni(String comando, String nomeRobot[], PartiDelRobot pdr[][]) { Scanner sc2 = new Scanner(System.in); int contatore = 0; String stat[] = {"", "", "", ""}; String Return = "Errore - si consiglia di picchiare il programmatore"; if (comando.equalsIgnoreCase("leftarmmove")) this.pdr[this.robotIndex][0].statoParte = !this.pdr[this.robotIndex][0].statoParte; else if (comando.equalsIgnoreCase("rightarmmove")) this.pdr[this.robotIndex][1].statoParte = !this.pdr[this.robotIndex][1].statoParte; else if (comando.equalsIgnoreCase("leftlegmove")) this.pdr[this.robotIndex][2].statoParte = !this.pdr[this.robotIndex][2].statoParte; else if (comando.equalsIgnoreCase("rightlegmove")) this.pdr[this.robotIndex][3].statoParte = !this.pdr[this.robotIndex][3].statoParte; else if (comando.equalsIgnoreCase("leftarmon")) this.pdr[this.robotIndex][0].statoParte = true; else if (comando.equalsIgnoreCase("rightarmon")) this.pdr[this.robotIndex][1].statoParte = true; else if (comando.equalsIgnoreCase("leftlegon")) this.pdr[this.robotIndex][2].statoParte = true; else if (comando.equalsIgnoreCase("rightlegon")) this.pdr[this.robotIndex][3].statoParte = true; else if (comando.equalsIgnoreCase("leftarmoff")) this.pdr[this.robotIndex][0].statoParte = false; else if (comando.equalsIgnoreCase("rightarmoff")) this.pdr[this.robotIndex][1].statoParte = false; else if (comando.equalsIgnoreCase("leftlegoff")) this.pdr[this.robotIndex][2].statoParte = false; else if (comando.equalsIgnoreCase("rightlegoff")) this.pdr[this.robotIndex][3].statoParte = false; else if (comando.equalsIgnoreCase("exploud")) { System.out.println ("Che atroce! Hai fatto esplodere il robottino " + nomeRobot[this.robotIndex] + "! Aspetta che te ne faccio un altro"); System.out.println ("..."); for (int i = 0; i < pdr[this.robotIndex].length; i++) { pdr[this.robotIndex][i].statoParte = false; } nomeRobot[this.robotIndex] = ""; return "Fatto, puoi continuare a giocare"; } else if (comando.equalsIgnoreCase("bier")) { System.out.println ("Il robottino " + nomeRobot[this.robotIndex] + "sta trangugiando una birra..."); System.out.println ("Buurrrrrrrrp!"); return "La birra analcolica fa schifo!"; } else if (comando.equalsIgnoreCase("rename")) { System.out.println ("Con questo comando quoi cambiare il nome del robottino " + nomeRobot[this.robotIndex]); System.out.println ("Digita il nuovo nome e premi invio per coninuare"); nomeRobot[this.robotIndex] = sc2.nextLine(); if (!(nomeRobot[this.robotIndex].equalsIgnoreCase(""))) nomeRobot[this.robotIndex] += " "; return "Ora il robottino si chiama " + nomeRobot[this.robotIndex]; } else if (comando.equalsIgnoreCase("porky")) { System.out.println ("Porky è un grande"); System.out.println ("Per maggiori informazioni visita il sito"); return "http://kakati.forumfree.net/"; } else if (comando.equalsIgnoreCase("xxx")) { System.out.println ("Il robottino " + nomeRobot[this.robotIndex] + "ha incontrato una bella robottina..."); return "*Censura*"; } else if (comando.equalsIgnoreCase("dance")) { System.out.println ("Immagini che il robottino " + nomeRobot[this.robotIndex] + " stia ballando..."); System.out.println ("Il robottino ha smesso di ballare"); for (int i = 0; i < pdr[this.robotIndex].length; i++) { pdr[0][i].statoParte = false; } return "Il robottino " + nomeRobot[this.robotIndex] + "si è fermato ed è tornato nella posizione originale"; } else if (comando.equalsIgnoreCase("newrobot")) { 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]; this.pdr = new PartiDelRobot[pdrAus.length][pdrAus[pdrAus.length-1].length]; for (int i=0; i