Skip to content

Commit 44f8aab

Browse files
committed
Polish
1 parent fd94672 commit 44f8aab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

printing-quotes/src/main/java/com/craftsmanshipinsoftware/prntqts/QuotesPrinter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class QuotesPrinter {
2020
void displayQuote() {
2121
try (Scanner scanner = new Scanner(this.inputStream)) {
2222
askForQuote();
23-
String quote = scanner.hasNext() ? scanner.nextLine() : null;
23+
String quote = readInput(scanner);
2424
askForAuthor();
25-
String author = scanner.hasNext() ? scanner.nextLine() : null;
25+
String author = readInput(scanner);
2626
if (quote == null || quote.isBlank()) {
2727
this.printStream.println("Please enter the quote!");
2828
} else if (author == null || author.isBlank()) {
@@ -41,4 +41,8 @@ private void askForAuthor() {
4141
System.out.print("Who said it? ");
4242
}
4343

44+
private String readInput(Scanner scanner) {
45+
return scanner.hasNext() ? scanner.nextLine() : null;
46+
}
47+
4448
}

0 commit comments

Comments
 (0)