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 {
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}
You can’t perform that action at this time.
0 commit comments