Giter Club home page Giter Club logo

itp-w3-oop-bookstore's Introduction

OOP Bookstore

Today, we're in charge of migrating our Bookstore project into an Object Oriented approach. The functionality will remain similar, but we'll use OOP to model our system.

For this project we have identified 3 key classes: Bookstore, Author and Book.

A Bookstore will be the starting point. You'll be able to add books and search from books in a bookstore object. In the following example, we'll create a bookstore and assign a book to it:

store = Bookstore("Rmotr's bookstore")
# No books yet
store.get_books() == []

# We create an author and book
borges = Author("Jorge Luis Borges", "Argentina")
ficciones = Book("Ficciones", author=borges)

# We add the book to the bookstore
store.add_book(ficciones)

store.get_books() == [<Object Book('ficciones')>]

The bookstore also has a "search" functionality. It works a little bit different than the previous one. In this case, you can search by book title or book author, or both title and author. The search method is the same one search_books, but you'll have to make it dynamic enough to support the three scenarios. Example:

# Searching *just* by title:
store.search_books(title='raven')

# Searching *just* by author:
poe = Author('Edgar Allan Poe', 'US')
store.search_books(author=poe)

# Searching by both title *and* author:
poe = Author('Edgar Allan Poe', 'US')
store.search_books(title='raven', author=poe)

Finally, the Book and Author classes have special relationships between them, and we want you to pay special attention to it.

Recommended path to test

You're welcome to choose your own way to work through this project. But given the structure of the classes, this is the path we suggest you to follow, the order to make the tests pass throughout the different test files.

1. Author's attributes

$ py.test test_authors.py -k test_author_creation

2. Books's attributes

$ py.test test_books.py

3. Author's relationship with books This is a special one because of the way we have to relate both authors with books and books with authors

$ py.test test_authors.py -k test_get_books_from_author

4. Bookstore Initialization

$ py.test test_bookstore.py -k test_instantiate_bookstore

5. Add Book to Bookstore

$ py.test test_bookstore.py -k test_add_book_to_bookstore

6. Search books by title

$ py.test test_bookstore.py -k test_search_bookstore_by_book_title

7. Search books by author

$ py.test test_bookstore.py -k test_search_bookstore_by_book_author

itp-w3-oop-bookstore's People

Contributors

santiagobasulto avatar ivanzugnoni avatar jsymons avatar martinzugnoni avatar mwilhite2316 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.