modulo 1 che magari mi fa prendere 18
This commit is contained in:
parent
73f362d715
commit
4d4a6f47fe
6 changed files with 74 additions and 2 deletions
BIN
Spirit_Arnaldo_Selvaggio/bin/Algoritmo.class
Normal file
BIN
Spirit_Arnaldo_Selvaggio/bin/Algoritmo.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
47
Spirit_Arnaldo_Selvaggio/src/Algoritmo.java
Normal file
47
Spirit_Arnaldo_Selvaggio/src/Algoritmo.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
|
||||||
|
// anche questa classe è interamente per il modulo 1
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Algoritmo {
|
||||||
|
private int nWords;
|
||||||
|
private ArrayList<String> encryptedWords;
|
||||||
|
private ArrayList<String> keyWords;
|
||||||
|
private ArrayList<String> resultWords;
|
||||||
|
|
||||||
|
public Algoritmo(int nWords, ArrayList<String> encryptedWords, ArrayList<String> keyWords) {
|
||||||
|
this.nWords = nWords;
|
||||||
|
this.encryptedWords = encryptedWords;
|
||||||
|
this.keyWords = keyWords;
|
||||||
|
doAlgorithm();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doAlgorithm() {
|
||||||
|
resultWords = new ArrayList<>();
|
||||||
|
for (int i = nWords / 2; i < nWords; i++) {
|
||||||
|
String encryptedWord = encryptedWords.get(i);
|
||||||
|
String keyWord = keyWords.get(i);
|
||||||
|
StringBuilder decryptedWord = new StringBuilder();
|
||||||
|
|
||||||
|
for (int j = 0; j < encryptedWord.length(); j++) {
|
||||||
|
int encryptedChar = (int) encryptedWord.charAt(j);
|
||||||
|
int keyChar = (int) keyWord.charAt(j);
|
||||||
|
int decryptedChar = (encryptedChar+ keyChar -97);
|
||||||
|
System.out.println("Encrypted char: " + encryptedChar);
|
||||||
|
System.out.println("Key char: " + keyChar);
|
||||||
|
System.out.println("Decrypted char: " + decryptedChar);
|
||||||
|
|
||||||
|
decryptedWord.append((char)decryptedChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
resultWords.add(decryptedWord.toString());
|
||||||
|
}
|
||||||
|
printResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printResult() {
|
||||||
|
for (String word : resultWords) {
|
||||||
|
System.out.println(word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,15 +59,21 @@ public class Giocatore {
|
||||||
this.sbleuri += this.tessereSbleuri;
|
this.sbleuri += this.tessereSbleuri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void aggiungiSbleuro(){
|
||||||
|
this.sbleuri ++;
|
||||||
|
}
|
||||||
|
|
||||||
public int posizionaTesseraTifoInveimento(Mappa mappa){
|
public int posizionaTesseraTifoInveimento(Mappa mappa){
|
||||||
int i = new Input().sceltaTifoInvimento(mappa);
|
int i = new Input().sceltaTifoInvimento(mappa);
|
||||||
boolean s = new Input().sceltaTifoInveimento();
|
boolean s = new Input().sceltaTifoInveimento();
|
||||||
if (s == true){
|
if (s == true){
|
||||||
mappa.getCasella(i).setTifoInveimento(1);
|
mappa.getCasella(i).setTifoInveimento(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mappa.getCasella(i).setTifoInveimento(-1);
|
mappa.getCasella(i).setTifoInveimento(-1);
|
||||||
}
|
}
|
||||||
|
setTesseraTifoInveimento(false);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,4 +102,6 @@ public class Giocatore {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@ import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
|
|
||||||
|
import it.kibo.fp.lib.InputData;
|
||||||
import it.kibo.fp.lib.Menu;
|
import it.kibo.fp.lib.Menu;
|
||||||
import it.kibo.fp.lib.RandomDraws;
|
import it.kibo.fp.lib.RandomDraws;
|
||||||
|
|
||||||
public class Partita {
|
public class Partita {
|
||||||
private static String titolo = "seleziona la scelta";
|
private static String titolo = "seleziona la scelta";
|
||||||
private static String [] selezioni = {"Lancia il dado", "usa la tessera tifo o inveimento", "scommetti su un cavallo", "giocati la casa", "visualizza la mappa", "visualizza i soldi di tutti"};
|
private static String [] selezioni = {"Lancia il dado", "usa la tessera tifo o inveimento", "scommetti su un cavallo", "giocati la casa", "visualizza la mappa", "visualizza i soldi di tutti", "Taunta un nemico"};
|
||||||
private static String titolo2 = "seleziona il cavallo su cui scommettere";
|
private static String titolo2 = "seleziona il cavallo su cui scommettere";
|
||||||
private static String [] selezioniCavalli ={"Nawt, Rosso", "Blanco, Blu", "Pound, Giallo", "Bang, Verde", "Bupkus, Viola"};
|
private static String [] selezioniCavalli ={"Nawt, Rosso", "Blanco, Blu", "Pound, Giallo", "Bang, Verde", "Bupkus, Viola"};
|
||||||
private Deque <Giocatore> giocatori = new ArrayDeque<>();
|
private Deque <Giocatore> giocatori = new ArrayDeque<>();
|
||||||
|
@ -102,6 +103,14 @@ public class Partita {
|
||||||
case 6:
|
case 6:
|
||||||
new Output().visualizzaSoldi(giocatori);
|
new Output().visualizzaSoldi(giocatori);
|
||||||
break;
|
break;
|
||||||
|
//sarebbe il modulo 1
|
||||||
|
/*case 7:
|
||||||
|
int nWords = InputData.readInteger("seleziona il numero di parole");
|
||||||
|
System.out.println("Enter " + nWords + " encrypted words followed by " + nWords + " key words:");
|
||||||
|
Input dati = new Input(nWords);
|
||||||
|
Algoritmo soluzione = new Algoritmo(nWords, dati.getEncryptedWords(), dati.getKeyWords());
|
||||||
|
|
||||||
|
break;*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,14 +122,22 @@ public class Partita {
|
||||||
}
|
}
|
||||||
|
|
||||||
}while(dado < 5);
|
}while(dado < 5);
|
||||||
|
fineTappa();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fineTappa(){
|
public void fineTappa(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finePartita(){
|
public void riscuotiTessereCavalli(){
|
||||||
|
ArrayList <Cavallo> classifica = new ArrayList<>();
|
||||||
|
for(int i = 0; i < cavalli.size(); i++){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finePartita(){
|
||||||
|
fineTappa();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue