Skip to content

Commit 9642c78

Browse files
committed
Add greeting functionality
1 parent 1f62543 commit 9642c78

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

app/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
run-dist:
2+
./build/install/app/bin/app

app/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ tasks.withType<JavaCompile> {
4040

4141
tasks.withType<JavaExec> {
4242
jvmArgs("--enable-preview")
43+
}
44+
tasks.getByName("run", JavaExec::class) {
45+
standardInput = System.`in`
4346
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package hexlet.code;
2+
import java.util.Scanner;
23

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

0 commit comments

Comments
 (0)