File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
printing-quotes/src/main/java/com/craftsmanshipinsoftware/prntqts Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ class QuotesPrinter {
20
20
void displayQuote () {
21
21
try (Scanner scanner = new Scanner (this .inputStream )) {
22
22
askForQuote ();
23
- String quote = scanner . hasNext () ? scanner . nextLine () : null ;
23
+ String quote = readInput ( scanner ) ;
24
24
askForAuthor ();
25
- String author = scanner . hasNext () ? scanner . nextLine () : null ;
25
+ String author = readInput ( scanner ) ;
26
26
if (quote == null || quote .isBlank ()) {
27
27
this .printStream .println ("Please enter the quote!" );
28
28
} else if (author == null || author .isBlank ()) {
@@ -41,4 +41,8 @@ private void askForAuthor() {
41
41
System .out .print ("Who said it? " );
42
42
}
43
43
44
+ private String readInput (Scanner scanner ) {
45
+ return scanner .hasNext () ? scanner .nextLine () : null ;
46
+ }
47
+
44
48
}
You can’t perform that action at this time.
0 commit comments