A library program to manage searches, lending and returning of books.
- clone the project
- import via IntelliJ IDEA
- I started with the full ISBN search as that only required complete string matching and would only be return a single book.
- For the partial author and title search, I initially grouped the search results into a set, as they cannot have duplicate elements and are unordered. I later reverted to returning the search results as a list for simplicity's sake.
- My approach to managing reference books was to add another field to each book that defaults to false. This meant that I didn't have to make any large changes to the way Library imports books.
- I refactored the tests to make them more readable by using a beforeEach block. This reduced the repetition caused by creating and seeding a new library with books.
- My initial approach to lending books was to add a copy of the book to a new listBuffer. I chose listBuffers as the collection would be changed frequently and thus would benefit from being mutable. I later created a separate Loan case class to keep track of who borrowed a book and when they borrowed it.
- ISBNs are unique
- Searches are case sensitive
- Libraries only have one copy of each book
- Start sbt
sbt
- Start the scala console
console
- Import the package
import com.company.library._
- Create a new Library
val library = new Library
-
Loans must include a name
-
Library.loan creates an object with the book, name, and date of loan
-
That book is now not in stock and also on loan
-
Returning a book reverses this and removes the loan
- Creating a date exceeding library LoanLength (LoanLength stored in a constant in the Library class)
- Creating a late loan and a new library with one book and that loan
-
Lending a book today
-
Finding all loans
-
Finding late loans
You have a library of books and are offering them to the world - you are lending so many books now that it is becoming hard to keep track of what you have. You decided to use your programming fu to build an application which can keep track of them for you.
- clone the project
- import via IntelliJ IDEA
- implements the user stories listed below (optional ones not required)
- compiles
- has tests
- frequent commits
As a visitor,
So that I can find books I am looking for,
I need to be able search books by partial title
As a visitor,
So that I can find books I am looking for,
I need to be able search books by partial author
As a visitor,
So that I can find books I am looking for,
I need to be able to search by full ISBN
As a librarian,
So that I can help my community,
I need to be able to lend books to visitors
As a librarian,
So that I can protect my expensive books,
I don't want to lend reference books
As a librarian,
So that I can manage my library correctly,
I need to know whether a book is available or on loan
As a librarian,
So that I can update my stock levels,
I need to be able update the library when a book is returned
As a librarian,
So that I can manage my library correctly,
I need to know who has a book that is on loan
As a librarian,
So that I can manage my library correctly,
I need to know which books are late
As a librarian,
So that I can manage my library correctly,
I need to know who has a book that is late
As a librarian,
So that I can manage my library correctly,
I want to fine users who are late returning their books