-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreeter.java
More file actions
29 lines (24 loc) · 751 Bytes
/
Copy pathGreeter.java
File metadata and controls
29 lines (24 loc) · 751 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
import java.util.Locale;
import java.util.ResourceBundle;
public class Greeter {
private Locale locale;
private String name;
public Greeter(String language, String country, String name) {
locale = new Locale(language, country);
this.name = name;
}
public String sayHello() {
ResourceBundle messages = ResourceBundle.getBundle("MessagesBundle", locale);
return messages.getString("greeting") + ", " + name.toUpperCase();
}
public static void main(String[] args) {
if (args.length < 3) {
System.exit(1);
}
String language = args[0];
String country = args[1];
String name = args[2];
Greeter greeter = new Greeter(language, country, name);
System.out.println(greeter.sayHello());
}
}