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
package org.perpustakaanku.model;
import java.util.ArrayList;
import java.util.List;
import org.perpustakaanku.model.Buku;
public class DaftarBuku {
private static List<Buku> bukus = new ArrayList<>();
static{
bukus.add(new Buku("1","Laravel","Awan Pribadi","LokoPedia",2));
bukus.add(new Buku("2","Matdis","Anthon","Gramedia",1));
bukus.add(new Buku("3","Longman TOEFL Test","Dewi","Philips",2));
bukus.add(new Buku("4","Motivasi","Ary Cahya","Grafindo",3));
bukus.add(new Buku("5","PABWE","Billy","Media",1));
}
/**
* @return the bukus
*/
public static List<Buku> getBukus() {
return bukus;
}
/**
* @param bukus the bukus to set
*/
public static void setBukus(List<Buku> bukus) {
DaftarBuku.bukus = bukus;
}
/**
*
* @param buku the bukus to add
*/
public static void addToListBukus(Buku buku){
DaftarBuku.bukus.add(buku);
}
/**
*
* @param judul judul from bukus
* @return bukus which has the same judul
*/
public static Buku getBukuFromList(String judul){
for(Buku buku : DaftarBuku.bukus){
if(buku.getJudul().compareTo(judul)==0){
return buku;
}
}
return null;
}
public static boolean isBukuExist(String judul){
for(Buku buku : bukus){
if(buku.getJudul().compareTo(judul)==0 && buku.getJumlah()!=0){
return true;
}
}
return false;
}
}