java · level 2 check
a little library.
Time to build a real app: a little library. The librarian types commands, one per line. The library keeps its books in a list, lends them out, takes them back and saves everything to a file, so nothing is lost when the program ends.
The commands are `add`, `lend`, `back`, `list`, `save`, `load` and `quit`, in any capitals. `add` asks for a title and an author, while `lend` and `back` ask for a title. `list` shows every book sorted by title, with a count. `save` writes `library.csv`, one book per line, and `load` reads it back, dropping any changes made since.
Each `Book` keeps its fields private and its status in an enum. Asking for a book that is not there throws your own checked `NoSuchBookException`, which the app catches and explains kindly. Fill in each `____` with what you learned in every unit, then run it and try your own commands.
Fill in every ____ then run the checks.
- 1 It lists books sorted by titleuses: collections
- 2 It lends books out and takes them backuses: objects
- 3 It explains kindly when a book is missinguses: exceptions
- 4 It saves to a file and loads it backuses: files
- 5 It copes when nothing has been saved yetuses: exceptions
- 6 It understands commands in any capitalsuses: text
Take as long as you like and try as many times as you want.
java · level 2 · medium
level up.
You passed every check. Your face is now B).
- 28 lessons in this level
- 6 of 6 checks passed
This pass isn’t saved. A free account keeps your new face.