Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.stream.IntStream;
- public class Library {
- private int id;
- private Catalog catalog;
- private int signUpProcessDays;
- private int shippableBooksPerDay;
- private float libraryScore;
- private int[] storedBooks;
- //constructor
- public Library(int id, int signUpProcessDays, int shippableBooksPerDay, int[] storedBooks, Catalog catalog) {
- this.id = id;
- this.catalog = catalog;
- this.signUpProcessDays = signUpProcessDays;
- this.shippableBooksPerDay = shippableBooksPerDay;
- this.storedBooks = storedBooks;
- computeScore();
- }
- /*
- private void checkBook (int[] books) {
- this.storedBooks = new int[books.length];
- for (int id : this.storedBooks) {
- id = 0;
- }
- for (int id : books) {
- this.storedBooks[id] = 1;
- }
- }
- */
- private void computeScore() {
- int[] books = catalog.getBooksById();
- int totalScore = 0;
- for (int id : this.storedBooks) {
- totalScore += books[id];
- }
- this.libraryScore = (totalScore/this.signUpProcessDays) * this.shippableBooksPerDay;
- }
- //getters
- public int getId() {
- return id;
- }
- public int getSignUpProcoessDays() {
- return signUpProcessDays;
- }
- public int getShippableBooksPerDay() {
- return shippableBooksPerDay;
- }
- public float getLibraryScore() {
- return libraryScore;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement