Skip to content

Commit 2785d2a

Browse files
committed
add Cli.java (greeting); add Makefile
1 parent 6ad3024 commit 2785d2a

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ tasks.test {
2222

2323
application {
2424
mainClass = "hexlet.code.App"
25-
}
25+
}
26+
27+
tasks.getByName("run", JavaExec::class) {
28+
standardInput = System.`in`
29+
}

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.greeting();
66
}
77
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package hexlet.code;
2+
3+
import java.util.Scanner;
4+
5+
public class Cli {
6+
public static void greeting() {
7+
System.out.println("Welcome to the Brain Games");
8+
Scanner scanner = new Scanner(System.in);
9+
System.out.println("May I have your name?");
10+
String name = scanner.next();
11+
System.out.println("Hello, " + name + "!");
12+
scanner.close();
13+
}
14+
}

0 commit comments

Comments
 (0)