-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathConsole.java
More file actions
41 lines (32 loc) · 970 Bytes
/
Console.java
File metadata and controls
41 lines (32 loc) · 970 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 io.zipcoder.common;
import java.util.Scanner;
public class Console {
public static void printWelcome(){
System.out.println("Number Of Pets");
}
public static void print(String output,Object... args){
System.out.printf(output, args);
}
public static void println(String output,Object... args){
print(output + "\n" + args);
}
public static String getStringInput(String prompt){
Scanner scanner = new Scanner(System.in);
println(prompt);
String userInput = scanner.nextLine();
return userInput;
}
public static Integer getIntegerInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
Integer userInput = 0;
try {
userInput = scanner.nextInt();
}
catch (Exception e)
{
System.out.println("Enter a valid number!");
}
return userInput;
}
}