-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.java
More file actions
99 lines (81 loc) · 2.33 KB
/
Library.java
File metadata and controls
99 lines (81 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import java.util.List;
public class Library {
private Integer ID;
private List<Book> books;
private Integer signUp;
private Integer perDay;
private Integer bookCount;
private Integer totalScore = 0;
private Integer maxDays;
private double perSignupDay;
public Library () {
}
public Library(List<Book> books, Integer signUp, Integer perDay, Integer id, Integer bookCount) {
this.books = books;
this.signUp = signUp;
this.perDay = perDay;
this.ID= id;
this.bookCount = bookCount;
}
public Integer getID() {
return ID;
}
public Integer getBookCount() {
return bookCount;
}
public void setBookCount(Integer bookCount) {
this.bookCount = bookCount;
}
public void setID(Integer ID) {
this.ID = ID;
}
public List<Book> getBooks() {
return books;
}
public void setBooks(List<Book> books) {
this.books = books;
}
public Integer getSignUp() {
return signUp;
}
public void setSignUp(Integer signUp) {
this.signUp = signUp;
}
public Integer getPerDay() {
return perDay;
}
public void setPerDay(Integer perDay) {
this.perDay = perDay;
}
public Integer getTotalScore() {
return totalScore;
}
public void setTotalScore(List<Book> scores, Integer day) {
int daysLeft = day-this.signUp-1;
int maxBookCount = daysLeft * this.perDay;
this.setBookCount(Math.min(maxBookCount, this.bookCount));
int maxTemp = 0;
for (int i = 0; i <Math.min(maxBookCount, this.bookCount) ; i++) {
maxTemp += this.books.get(i).getScore();
}
this.totalScore = maxTemp;
}
public void setMaxDays(Integer day){
if (this.signUp<day) {
int daysLeft = day - this.signUp - 1;
int maxBookCount = daysLeft * this.perDay;
this.maxDays = (int) Math.ceil(Math.min(maxBookCount, this.bookCount) / this.perDay) + signUp;
}else {
this.maxDays = this.signUp;
}
}
public Integer getMaxDays() {
return maxDays;
}
public double getPerSignupDay() {
return perSignupDay;
}
public void setPerSignupDay() {
this.perSignupDay = this.totalScore/this.perSignupDay;
}
}