-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameScores.java
More file actions
29 lines (25 loc) · 851 Bytes
/
Copy pathGameScores.java
File metadata and controls
29 lines (25 loc) · 851 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.Scanner;
public class GameScores {
public String getName() {
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
}
public String getScore() {
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
}
public void printScore(String name, String score) {
System.out.println(name + "'s high score: " + score);
}
public static void main(String[] args) {
GameScores game = new GameScores();
while (true) {
System.out.println("Enter name: ");
String name = game.getName();
if (name.isEmpty()) break;
System.out.println("Enter high score: ");
String score = game.getScore();
game.printScore(name, score);
}
}
}