File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .javabooks ;
2+
3+ import java .util .List ;
4+ import java .util .Scanner ;
5+
6+ public class ConsoleUI {
7+
8+ private final Scanner scanner = new Scanner (System .in );
9+
10+ public void printMenu (){
11+ System .out .println ("\n ====== JavaBooks ======" );
12+ System .out .println ("1. Add book" );
13+ System .out .println ("2. List books" );
14+ System .out .println ("3. Search" );
15+ System .out .println ("4. Borrow" );
16+ System .out .println ("5. Return" );
17+ System .out .println ("6. Remove" );
18+ System .out .println ("7. Sort" );
19+ System .out .println ("8. Statistics" );
20+ System .out .println ("9. Save" );
21+ System .out .println ("10. Load" );
22+ System .out .println ("0. Exit" );
23+ System .out .print ("Choose: " );
24+ }
25+
26+ public int askInt (String msg ){
27+ System .out .print (msg );
28+ return Integer .parseInt (scanner .nextLine ());
29+ }
30+
31+ public String ask (String msg ){
32+ System .out .print (msg );
33+ return scanner .nextLine ();
34+ }
35+
36+ public void printBooks (List <Book > books ){
37+ if (books .isEmpty ()){
38+ System .out .println ("No books." );
39+ return ;
40+ }
41+ books .forEach (System .out ::println );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments