-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVotante.java
More file actions
41 lines (33 loc) · 959 Bytes
/
Votante.java
File metadata and controls
41 lines (33 loc) · 959 Bytes
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
package prg.es3;
public class Votante{
private String phone;
private int voteCounter;
public Votante(String phone){
this.setPhone(phone);
}
public Votante setPhone(String phoneNumber){
this.phone = phoneNumber;
return this;
}
public String getPhone(){
return this.phone;
}
private Votante setVoteCounter(int number){ //private: non do la possibilità di settare voteCounter al di fuori di questa classe ma solo di incrementarlo
this.voteCounter = number;
return this;
}
public int getVoteCounter(){
return voteCounter;
}
public Votante increaseVoteCounter(){
if(this.getVoteCounter() < 5){
this.setVoteCounter(this.getVoteCounter()+1);
} else {
System.out.println("Numero massimo di voti gia' raggiunto per " + this.getPhone());
}
return this;
}
public String toString(){
return "Numero telefono: " + this.getPhone() + " Numero voti: " + this.getVoteCounter();
}
}