Skip to content

Commit 279c9b8

Browse files
committed
add welcoming method
1 parent 621a76a commit 279c9b8

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@ dependencies {
2121

2222
tasks.test {
2323
useJUnitPlatform()
24+
}
25+
26+
tasks.getByName("run", JavaExec::class) {
27+
standardInput = System.`in`
2428
}

app/src/main/java/hexlet/code/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public class App {
44
public static void main(String[] args) {
5-
System.out.println("Welcome to the Brain Games!");
5+
Cli.welcomeUser();
66
}
77
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package hexlet.code;
2+
3+
import java.util.Scanner;
4+
5+
public class Cli {
6+
public static void welcomeUser() {
7+
Scanner scanner = new Scanner(System.in);
8+
9+
System.out.println("Welcome to the Brain Games!");
10+
System.out.print("May I have your name? ");
11+
String userName = scanner.next();
12+
System.out.println("Hello, " + userName + "!");
13+
14+
scanner.close();
15+
}
16+
}
17+

0 commit comments

Comments
 (0)