Aggioranta la classe film con il fix dei posti e l'aggiunta delle classi toString e vendiBiglietti come boolean
This commit is contained in:
parent
104c9f5ea3
commit
3bd5c5655e
|
@ -2,20 +2,34 @@
|
||||||
* Classe che va a rappresentare un film
|
* Classe che va a rappresentare un film
|
||||||
*
|
*
|
||||||
* @autor Ciausu Angelo
|
* @autor Ciausu Angelo
|
||||||
* @version 1.0
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
public class Film {
|
public class Film {
|
||||||
|
|
||||||
private String titolo;
|
private String titolo;
|
||||||
private int durata;
|
private int durata;
|
||||||
private String sala;
|
private String sala;
|
||||||
private int posti;
|
private int postiTotali;
|
||||||
|
private int postiRimasti;
|
||||||
|
|
||||||
public Film(String titolo, int durata, String sala, int posti) {
|
public Film(String titolo, int durata, String sala, int posti) {
|
||||||
this.titolo = titolo;
|
this.titolo = titolo;
|
||||||
this.durata = durata;
|
this.durata = durata;
|
||||||
this.sala = sala;
|
this.sala = sala;
|
||||||
this.posti = posti;
|
this.postiTotali = posti;
|
||||||
|
this.postiRimasti = posti;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean vendiBiglietti(int numeroBiglietti) {
|
||||||
|
if (numeroBiglietti <= postiRimasti) {
|
||||||
|
postiRimasti = postiRimasti - numeroBiglietti;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "Film: " + titolo + " (Durata: " + durata + " min)" + " - Sala: " + sala + " - Posti: " + postiRimasti;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitolo() {
|
public String getTitolo() {
|
||||||
|
@ -30,12 +44,6 @@ public class Film {
|
||||||
return sala;
|
return sala;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPosti() {
|
public int getPostiRimasti() {return postiRimasti;}
|
||||||
return posti;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosti(int posti) {
|
|
||||||
this.posti = posti;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue