From f9bbfa501910f1423d7a4959a46aea4e45eab532 Mon Sep 17 00:00:00 2001 From: Mr SL1D3R <76396365+Mr-sl1d3r@users.noreply.github.com> Date: Wed, 5 Mar 2025 08:38:56 +0100 Subject: [PATCH] Aggioranto con la risposta al problema n*1 --- risposte.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/risposte.md b/risposte.md index 81d30b5..45c9b9d 100644 --- a/risposte.md +++ b/risposte.md @@ -3,6 +3,23 @@ ## Problema 1 Perché il main stampa 16 volte "Film non trovato"? Quale è l'errore? Individua la causa e spiegamela come risposta. + - Il problema che sono riuscito ad inviduare è il seguente: il fatto che essendo andato a fare per 4 volte prenotaPosti, e la funzione prenotaPosti è fatta cosi + ```java + public void prenotaPosti(int Posti, Film film){ + for (int i = 0; i < this.film.length; i++) { + if (this.film[i] == film) { + if (this.film[i].getPosti() >= Posti) { + this.film[i].setPosti(this.film[i].getPosti() - Posti); + } else { + System.out.println("Posti non disponibili"); + } + }else { + System.out.println("Film non trovato"); + } + } + } + ``` + Vado a fare un controllo in tutto l'array e dato che non viene trovato quel film andiamo nel else che stampa film non trovato. Per questo motivo viene stampato 16 volte "Film non trovato". ## Problema 2 (classe Film)