-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScannerPro.java
42 lines (35 loc) · 908 Bytes
/
ScannerPro.java
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
package prg.es1;
import java.util.Scanner;
public class ScannerPro{
private static ScannerPro instance;
private Scanner scanner;
private ScannerPro(){
scanner = new Scanner(System.in);
}
public static ScannerPro getInstance(){
if(instance == null){
instance = new ScannerPro();
}
return instance;
}
public String insertName(){
System.out.print("Inserisci nome: ");
return instance.scanner.next();
}
public String insertSurname(){
System.out.print("Inserisci cognome: ");
return instance.scanner.next();
}
public int insertEta(){
System.out.print("Inserisci eta': ");
return instance.scanner.nextInt();
}
public String insertString(String message){
System.out.print(message);
return instance.scanner.next();
}
public int insertInt(String message){
System.out.print(message);
return instance.scanner.nextInt();
}
}