-
Notifications
You must be signed in to change notification settings - Fork 0
/
BookShop.java
61 lines (49 loc) · 1.38 KB
/
BookShop.java
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package protoType;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author majid
*/
public class BookShop implements Cloneable{
private String shop_name;
private List<Book> books = new ArrayList();
public String getShop_name() {
return shop_name;
}
public void setShop_name(String shop_name) {
this.shop_name = shop_name;
}
public List<Book> getBooks() {
return books;
}
public void setBooks(List<Book> books) {
this.books = books;
}
public void loadData(){
for (int i=1;i<=10;i++){
Book b = new Book();
b.setBookName("Book "+i);
b.setBook_id(i);
books.add(b);
}
}
@Override
public String toString() {
return "shop_name=" + shop_name + ", books=" + books + '\n';
}
@Override
@SuppressWarnings("CloneDoesntCallSuperClone")
protected BookShop clone() throws CloneNotSupportedException {
BookShop bshp= new BookShop();
this.getBooks().stream().forEach((b) -> {
bshp.books.add(b);
});
return bshp;
}
}