Code Monkey home page Code Monkey logo

bookstore's Introduction

OOP Bookstore

Context

We have learned Object-Oriented Programming and how class and inheritance work in JavaScript. Now, let's apply all of the concepts we have just learned and build an OOP based approach to the book store with a lot of books in it.

Task & Objectives

You will be working in the solution.js file and the tests you can reference are in the solution.test.js file. To check on your progress and if you are passing the tests, you can click on the "Run Tests" button. To submit your work, you should click on the "Submit" button. You will be asked to review your test and make a final submission. After you are done with the final submission, you can't resubmit afterward.

1. Define the classes

  • Create two classes, one for the Bookstore and another for each Book. Hint: These two classes are not extending each other, they are just 2 separate classes.
  • Bookstore class

    • Should receive a name to it's name property.
    • Should have books property to store the books.
  • Book class

    • Should receive a name and the quantity.
    • Should have a name and quantity property.

2. Define the methods

Bookstore

The Bookstore class should have methods for:

  1. Pick a book: pickBook method

    • Should receive a book name.
    • Should check if it exists, and if not, it should return the message: "Book not found".
    • Should check if the book is available due to the quantity of the books, and if there are no books available (quantity property equals 0), it should return the message: "Not available". If the book exists and it's available then subtract one book from the book quantity and return the book.
  2. Store a book: storeBook method

    • Should receive a book and add it to the books property.
  3. Show books: showBooks method

    • Should show every book on the console.

Book

The Book class just needs a method to change the book name:

  1. Change the name: changeName method -

    • Should receive a new book name and set the name property to it.

Good luck!

-Your Ironhack team

bookstore's People

Contributors

kostra0ne 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.