neZnam121

Untitled

Feb 19th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. class LibraryCollection{
  2.     constructor(capacity){
  3.         this.capacity=capacity;
  4.         this.books=[];
  5.     }
  6.     addBook (bookName, bookAuthor){
  7.          
  8.         for (let i = 0; i < this.books.length; i++) {
  9.            if( this.books[i] == null){
  10.             throw new Error("Not enough space in the collection.")
  11.            }else{
  12.             let book={
  13.                 bookName:bookName,
  14.                 bookAuthor:bookAuthor,
  15.                 payed: false,
  16.             }
  17.            
  18.             this.books.push(book)
  19.  
  20.             return "The {bookName}, with an author {bookAuthor}, collect.";
  21.         }
  22.     }
  23.        
  24.  
  25.     }  
  26.  
  27.     payBook( bookName ) {
  28.         if(!this.books.some(x => x.bookName == bookName)){
  29.             throw new Error(`${bookName} is not in the collection.`)
  30.         }
  31.         if (this.books.some(x => x.payed=)) {
  32.            
  33.         }
  34.     }
  35.     removeBook(bookName) {
  36.  
  37.     }
  38.     getStatistics(bookAuthor){
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment