modulo 1 che magari mi fa prendere 18

This commit is contained in:
gababababibbo 2025-06-09 17:47:23 +02:00
parent 73f362d715
commit 4d4a6f47fe
6 changed files with 74 additions and 2 deletions

Binary file not shown.

View 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);
}
}
}

View file

@ -59,15 +59,21 @@ public class Giocatore {
this.sbleuri += this.tessereSbleuri;
}
public void aggiungiSbleuro(){
this.sbleuri ++;
}
public int posizionaTesseraTifoInveimento(Mappa mappa){
int i = new Input().sceltaTifoInvimento(mappa);
boolean s = new Input().sceltaTifoInveimento();
if (s == true){
mappa.getCasella(i).setTifoInveimento(1);
}
else{
mappa.getCasella(i).setTifoInveimento(-1);
}
setTesseraTifoInveimento(false);
return i;
}
@ -96,4 +102,6 @@ public class Giocatore {
}
}

View file

@ -2,12 +2,13 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import it.kibo.fp.lib.InputData;
import it.kibo.fp.lib.Menu;
import it.kibo.fp.lib.RandomDraws;
public class Partita {
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 [] selezioniCavalli ={"Nawt, Rosso", "Blanco, Blu", "Pound, Giallo", "Bang, Verde", "Bupkus, Viola"};
private Deque <Giocatore> giocatori = new ArrayDeque<>();
@ -102,6 +103,14 @@ public class Partita {
case 6:
new Output().visualizzaSoldi(giocatori);
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,15 +122,23 @@ public class Partita {
}
}while(dado < 5);
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();
}
}