Giter VIP home page Giter VIP logo

automated-library-system's Introduction

libExample

An automated library system for users and books. Main classes are:

LibOrganizer:

Is the main part of the library. Organizes people and books in an efficient way. It has "LibExceptions" enum class and throws one of its values in case of error:
  • bookNotFound
  • bookNotAvailable
  • bookTitleAlreadyExists
  • bookISBNAlreadyExists
  • bookAlreadyBought
  • userAlreadyExists
  • userNotFound
It has also the following functions:

- LibOrganizer(std::function buyBookFunction)

Paramter is a call-back function, to be called after every request after 50th request.

- void borrowBook(std::string userName, std::string BookTitle)

this function is to be called when a user called $userName borrows a book called $Booktitle.

- void returnBook(std::string userName, std::string BookTitle)

this function is to be called when a user returns a book.

- void requestBook(std::string BookTitle, std::string author, std::string ISBN)

This function is to be called when user requests a book (throws BookException::hasBeenRequestedFromThisUser).

- Book& buyBook(std::string title, std::string author, std::string ISBN)

this function is to be called when a new Book is bought to be added to the repository.

- User& addUser(std::string name)

adds new user to to librarry

- Book& findBookPerTitle(const std::string& title)

returns the book with corresponding title from the repo.

- Book& findBookPerISBN(const std::string& ISBN)

returns the book with corresponding ISBN from the repo.

- User& findUserPerName(const std::string& userName)

returns the user with corresponding name from the repo.


User:

User Class implements a library user. It has the functionality. It has "UserException" enum class and throws one of its values in case of error:
  • reachedMaxNumberOfBooks
  • noSuchBook
It has the following functions:

- User(std::string name)

creates a new user with User.name = name

- void borrowBook(Book& book)

add the borrowed book to the list of borrowed books of the user(a list of 10 books

- void returnBook(Book& book)

remove the book from the list of borrowed books of the user

- std::string getName()

return name of the user

- std::string toString()

return user data as a string


Book:

Book class represent a book with a titile, author, ISBN and a potential borrower. It has "BookException" enum class and throws one of its values as exceptions:
  • notAvailable
  • notInRequest
  • notBorrowed
  • hasBeenRequestedFromThisUser
It has also "BookStatus" enum class which has the following potential values:
  • available
  • borrowed
  • inRequest
It offers the following functions:

- Book(std::string title, std::string author, std::string ISBN, BookStatus status)

creates a new book with given parameters.

- int request(User* user)

increases request counter if user hasn't already requested and returns the new val.

- bool isAvailable()

return true if book status is available (already bought and not borrowed).

- void borrow(User* user)

change book status to borrowed and saved the borrowing user.

- int returnBook()

change book status to available.

- void buyFromWaitingList()

change book status from requested to availalbe

- std::string toString()

return book data as a string

- User* getUser()

shows the book borrower or throws exception if not borrowed

- std::string getTitle()

returns book title

- std::string getISBN()

returns book isbn

- std::string getAuthor()

returns book author

- BookStatus getStatus()

return book status of data Type Book::Status


P.S.

  1. callback functions is called once a book is requested. You can buy the book automatically in the function as in the example-3.
  2. You can use makefile to build the project writing the command "make".
  3. All actions happen in O(log(N)) time-complexity and O(N) place-complexity where N is the number of exisiting elemenst(users, books..).
  4. In user class books array has at most a constant of 10 elements that's why adding in linear time doesn't yield a bigger complexity.

automated-library-system's People

Contributors

narekb95 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  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.