aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/reading/models/Book.scala
blob: 1e4b81a3b663d53b3223c5253eeb2fc39d992185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package reading.models

case class Book(
  title: String,
  author: String,
  genres: Seq[Genre],
  themes: Seq[Theme]
)

object Book {
  def all: Seq[Book] = Seq(
    Book("Les dix petits nègres", "Agatha Christie", Seq(Genre.Detective), Seq(Theme.Fear)),
    Book("Le joueur", "Fiódor Dostoyevski", Seq(Genre.Adventure), Seq(Theme.Fear)),
    Book("Voyage au bout de la nuit", "Céline", Seq(Genre.Adventure), Seq(Theme.Fear)),
    Book("Le petit prince", "Antoine de Saint Exupéry", Seq(Genre.Adventure), Seq(Theme.Friendship)),
    Book("Les frères Karamazov", "Fiódor Dostoyevski", Seq(Genre.Adventure), Seq(Theme.Family))
  )

  def filter(books: Seq[Book], filters: Seq[Filter]): Seq[Book] =
    books.filter(b => filters.forall(_.filter(b)))
}