1.3-Object-Georienteerd-Programmeren

Library

We are going to create a library application. You can borrow books and/or DVDs from the library. The objects that you want to borrow all have a barcode (a series of numbers, id in your csv files) and a title. Furthermore, books have an ISBN number (text) and an author. DVDs, besides barcode and title, also have a rating and a year of release.

The library contains a list of books and a list of DVDs, where each item to be loaned (i.e. book or DVD) knows whether it has been loaned out (or not). The lists of both books and DVD’s must be read from the supplied files “books.csv” and “dvds.csv” respectively (see Files).

At the start of the application, all objects are automatically loaded from the csv files. After that, the librarian (the user) has the possibility to:

In the output below, we visualised lent objects with an *.

Of course, your program should ensure that when lending out or taking back books, only a list of the relevant books is shown. Also, throw proper exceptions if something illegal is attempted.

Hint: Remember the OptionSelector exercise from ealier? Try to understand why such a class would make your life easier (and use it in your solution!).

Example

Below we have given you a possible output for your application. Obviously your layout may differ a little as long as the functionality remains the same.

Read 6 books and 6 dvds!

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: c
Selected option = 'C'

Collection:
  - Book - Fundamentals of Business Process Management (1000000001), isbn: 9783662565087, author: Dumas, Marlon,
  - Book - ICT Methodspack (1000000002), isbn: 9990002067426, author: diverse
  - Book - CompTIA A+ Complete Study Guide (1000000003), isbn: 9781119515937, author: Quentin Docter
  - Book - Gedrag in organisaties met MyLab NL toegangscode (1000000004), isbn: 9789043037204, author: Robbins, Stephen P.
  - Book - Essenties van verandermanagement (1000000005), isbn: 9789013105278, author: Witte, Marco de. Jonker, Jan. Vink, Maurits Jan
  - Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,
  - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition) (2000000001), rating: R, year: 1989
  - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition/ Blu-ray) (2000000002), rating: R, year: 1989
  - Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
  - Dvd - Enter The Wild (2000000004), rating: NR, year: 2018
  - Dvd - Global Meltdown (2000000005), rating: NR, year: 2017
  - Dvd - It Happened In L.A. (2000000006), rating: NR, year: 2017
  === END OF LIST ===

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: o
Selected option = 'O'

*************** LibraryObject selector ***************
1) - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition) (2000000001), rating: R, year: 1989
2) - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition/ Blu-ray) (2000000002), rating: R, year: 1989
3) - Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
4) - Dvd - Enter The Wild (2000000004), rating: NR, year: 2018
5) - Dvd - Global Meltdown (2000000005), rating: NR, year: 2017
6) - Dvd - It Happened In L.A. (2000000006), rating: NR, year: 2017
7) - Book - Fundamentals of Business Process Management (1000000001), isbn: 9783662565087, author: Dumas, Marlon,
8) - Book - ICT Methodspack (1000000002), isbn: 9990002067426, author: diverse
9) - Book - CompTIA A+ Complete Study Guide (1000000003), isbn: 9781119515937, author: Quentin Docter
10) - Book - Gedrag in organisaties met MyLab NL toegangscode (1000000004), isbn: 9789043037204, author: Robbins, Stephen P.
11) - Book - Essenties van verandermanagement (1000000005), isbn: 9789013105278, author: Witte, Marco de. Jonker, Jan. Vink, Maurits Jan
12) - Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,

Please select a value: 3
Lend out:
- Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
  === END OF LIST ===

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: o
Selected option = 'O'

*************** LibraryObject selector ***************
1) - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition) (2000000001), rating: R, year: 1989
2) - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition/ Blu-ray) (2000000002), rating: R, year: 1989
3) - Dvd - Enter The Wild (2000000004), rating: NR, year: 2018
4) - Dvd - Global Meltdown (2000000005), rating: NR, year: 2017
5) - Dvd - It Happened In L.A. (2000000006), rating: NR, year: 2017
6) - Book - Fundamentals of Business Process Management (1000000001), isbn: 9783662565087, author: Dumas, Marlon,
7) - Book - ICT Methodspack (1000000002), isbn: 9990002067426, author: diverse
8) - Book - CompTIA A+ Complete Study Guide (1000000003), isbn: 9781119515937, author: Quentin Docter
9) - Book - Gedrag in organisaties met MyLab NL toegangscode (1000000004), isbn: 9789043037204, author: Robbins, Stephen P.
10) - Book - Essenties van verandermanagement (1000000005), isbn: 9789013105278, author: Witte, Marco de. Jonker, Jan. Vink, Maurits Jan
11) - Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,

Please select a value: 11
Lend out:
- Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,
- Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
  === END OF LIST ===

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: l
Selected option = 'L'

Lend out:
- Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,
- Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
  === END OF LIST ===

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: i
Selected option = 'I'

*************** LibraryObject selector ***************
1) - Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
2) - Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,

Please select a value: 1
Lend out:
- Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,
  === END OF LIST ===

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: c
Selected option = 'C'

Collection:
  - Book - Fundamentals of Business Process Management (1000000001), isbn: 9783662565087, author: Dumas, Marlon,
  - Book - ICT Methodspack (1000000002), isbn: 9990002067426, author: diverse
  - Book - CompTIA A+ Complete Study Guide (1000000003), isbn: 9781119515937, author: Quentin Docter
  - Book - Gedrag in organisaties met MyLab NL toegangscode (1000000004), isbn: 9789043037204, author: Robbins, Stephen P.
  - Book - Essenties van verandermanagement (1000000005), isbn: 9789013105278, author: Witte, Marco de. Jonker, Jan. Vink, Maurits Jan
* - Book - CompTIA Network+ N10-007 Cert Guide (1000000006), isbn: 9780789759818, author: Sequeira, Anthony,
  - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition) (2000000001), rating: R, year: 1989
  - Dvd - Innocent Man (1989/ Kino Lorber Studio Classics/ Special Edition/ Blu-ray) (2000000002), rating: R, year: 1989
  - Dvd - John Wick / John Wick: Chapter 2 (2000000003), rating: R, year: 2017
  - Dvd - Enter The Wild (2000000004), rating: NR, year: 2018
  - Dvd - Global Meltdown (2000000005), rating: NR, year: 2017
  - Dvd - It Happened In L.A. (2000000006), rating: NR, year: 2017
  === END OF LIST ===

[C]ollection, [L]end list, lend [O]ut, take back [I]n or e[X]it: x
Selected option = 'X'

Exiting...

Files