Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. import java.util.stream.IntStream;
  2.  
  3. public class Library {
  4.  
  5.     private int id;
  6.  
  7.     private Catalog catalog;
  8.  
  9.     private int signUpProcessDays;
  10.     private int shippableBooksPerDay;
  11.     private float libraryScore;
  12.  
  13.     private int[] storedBooks;
  14.  
  15.  
  16.     //constructor
  17.     public Library(int id, int signUpProcessDays, int shippableBooksPerDay, int[] storedBooks, Catalog catalog) {
  18.  
  19.         this.id = id;
  20.         this.catalog = catalog;
  21.         this.signUpProcessDays = signUpProcessDays;
  22.         this.shippableBooksPerDay = shippableBooksPerDay;
  23.         this.storedBooks = storedBooks;
  24.  
  25.         computeScore();
  26.  
  27.     }
  28.  
  29.     /*
  30.     private void checkBook (int[] books) {
  31.  
  32.         this.storedBooks = new int[books.length];
  33.  
  34.         for (int id : this.storedBooks) {
  35.             id = 0;
  36.         }
  37.  
  38.         for (int id : books) {
  39.             this.storedBooks[id] = 1;
  40.         }
  41.  
  42.     }
  43.     */
  44.  
  45.     private void computeScore() {
  46.  
  47.         int[] books = catalog.getBooksById();
  48.         int totalScore = 0;
  49.  
  50.         for (int id : this.storedBooks) {
  51.             totalScore += books[id];
  52.         }
  53.         this.libraryScore = (totalScore/this.signUpProcessDays) * this.shippableBooksPerDay;
  54.     }
  55.  
  56.     //getters
  57.     public int getId() {
  58.         return id;
  59.     }
  60.  
  61.     public int getSignUpProcoessDays() {
  62.         return signUpProcessDays;
  63.     }
  64.  
  65.     public int getShippableBooksPerDay() {
  66.         return shippableBooksPerDay;
  67.     }
  68.  
  69.     public float getLibraryScore() {
  70.         return libraryScore;
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement