-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
91 lines (63 loc) · 3.6 KB
/
Main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
public class Main {
private static final String YOU_PROVIDED = "You provided: ";
public static void main(String[] args) {
System.out.println("\nNow testing without loop, without message");
testWithoutMessage(false);
System.out.println("\nNow testing with loop, without message");
testWithoutMessage(true);
System.out.println("\nNow testing without loop, with message");
testWithMessage(false);
System.out.println("\nNow testing with loop, with message");
testWithMessage(true);
}
private static void testWithoutMessage(boolean shouldLoop) {
BetterScanner scanner = new BetterScanner(shouldLoop);
System.out.println("Provide a big decimal:");
System.out.println(YOU_PROVIDED + scanner.nextBigDecimal());
System.out.println("Provide a big integer:");
System.out.println(YOU_PROVIDED + scanner.nextBigInteger());
System.out.println("Provide a boolean:");
System.out.println(YOU_PROVIDED + scanner.nextBoolean());
System.out.println("Provide a byte:");
System.out.println(YOU_PROVIDED + scanner.nextByte());
System.out.println("Provide an character:");
System.out.println(YOU_PROVIDED + scanner.nextChar());
System.out.println("Provide a double:");
System.out.println(YOU_PROVIDED + scanner.nextDouble());
System.out.println("Provide a float:");
System.out.println(YOU_PROVIDED + scanner.nextFloat());
System.out.println("Provide an integer:");
System.out.println(YOU_PROVIDED + scanner.nextInt());
System.out.println("Provide a long:");
System.out.println(YOU_PROVIDED + scanner.nextLong());
System.out.println("Provide a short:");
System.out.println(YOU_PROVIDED + scanner.nextShort());
System.out.println("Provide a string:");
System.out.println(YOU_PROVIDED + scanner.nextString());
}
private static void testWithMessage(boolean shouldLoop) {
BetterScanner scanner = new BetterScanner(shouldLoop);
System.out.println("Provide a big decimal:");
System.out.println(YOU_PROVIDED + scanner.nextBigDecimal("Invalid big decimal. Please try again:"));
System.out.println("Provide a big integer:");
System.out.println(YOU_PROVIDED + scanner.nextBigInteger("Invalid big integer. Please try again:"));
System.out.println("Provide a boolean:");
System.out.println(YOU_PROVIDED + scanner.nextBoolean());
System.out.println("Provide a byte:");
System.out.println(YOU_PROVIDED + scanner.nextByte("Invalid byte. Please try again:"));
System.out.println("Provide an character:");
System.out.println(YOU_PROVIDED + scanner.nextChar("Invalid char. Please try again:"));
System.out.println("Provide a double:");
System.out.println(YOU_PROVIDED + scanner.nextDouble("Invalid double. Please try again:"));
System.out.println("Provide a float:");
System.out.println(YOU_PROVIDED + scanner.nextFloat("Invalid float. Please try again:"));
System.out.println("Provide an integer:");
System.out.println(YOU_PROVIDED + scanner.nextInt("Invalid int. Please try again:"));
System.out.println("Provide a long:");
System.out.println(YOU_PROVIDED + scanner.nextLong("Invalid long. Please try again:"));
System.out.println("Provide a short:");
System.out.println(YOU_PROVIDED + scanner.nextShort("Invalid short. Please try again:"));
System.out.println("Provide a string:");
System.out.println(YOU_PROVIDED + scanner.nextString());
}
}