-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServizio.java
More file actions
51 lines (42 loc) · 1.09 KB
/
Servizio.java
File metadata and controls
51 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package prg.es2;
import java.util.ArrayList;
public class Servizio{
ArrayList<Abbonato> clienti;
public Servizio(){
clienti = new ArrayList<>();
}
public void newAbbonato(Abbonato newAbb){
this.clienti.add(newAbb);
}
public void newAbbonato(String nome, String cognome, int eta, boolean abbonatoPremium){
Abbonato newAbb;
if(abbonatoPremium == true){
newAbb = new AbbonatoPremium(nome, cognome, eta);
} else {
newAbb = new Abbonato(nome, cognome, eta);
}
this.clienti.add(newAbb);
}
public void deleteAbbonato(int id){
this.clienti.remove(id);
}
public Abbonato getAbbonato(int id){
return this.clienti.get(id);
}
public void printAbbonati(){
System.out.println("Lista abbonati: ");
for(Abbonato abb : this.clienti){
if(abb instanceof Abbonato){
System.out.println(abb.toString());
}
}
}
public void printAbbonatiPremium(){
System.out.println("Lista abbonati premium: ");
for(Abbonato abb : this.clienti){
if(abb instanceof AbbonatoPremium){
System.out.println(abb.toString());
}
}
}
}