This repository was archived by the owner on May 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopy.java
More file actions
185 lines (162 loc) · 3.6 KB
/
Copy.java
File metadata and controls
185 lines (162 loc) · 3.6 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import java.util.List;
import java.util.ArrayList;
/*
* TO DO: implement history list (borrow & returns)
*/
/**
* @author Suman Gurung
* @author Dale Butt
* This class represent a copy of a particular resource (DVD, Book, Laptop)
*
*/
public class Copy {
/**
* The attributes/variables/fields of a copy of resource
*/
private int copyID;
private Book book;
private DVD dvd;
private Laptop laptop;
private String loanDuration;
private String dueDate;
private boolean available; // if is being loaned then this will be false (fitering)
private List<User> history = new ArrayList<User>();
/**
* Constructor of copy of a book
* @param book detail of a book
* @param loanDuration the duration that the copy of the book is loaned for
*/
public Copy(Book book, String loanDuration) {
setBook(book);
setCopyID();
setLoanDuration(loanDuration);
setAvailable(true);
}
/**
* Constructor of copy of a DVD
* @param dvd detail of a DVD
* @param loanDuration the duration that the copy of the DVD is loaned for
*/
public Copy(DVD dvd, String loanDuration) {
setDVD(dvd);
setCopyID();
setLoanDuration(loanDuration);
setAvailable(true);
}
/**
* Constructor of copy of a laptop
* @param laptop detail of a laptop
* @param loanDuration the duration that the copy of the laptop is loaned for
*/
public Copy(Laptop laptop, String loanDuration) {
setLaptop(laptop);
setCopyID();
setLoanDuration(loanDuration);
setAvailable(true);
}
/**
* Getting the duration that the copy of the resource is loaned for
* @return loanDuration
*/
public String getLoanDuration() {
return loanDuration;
}
/**
* Getting the date on which the copy of the resource needs to be returned to library
* @return dueDate
*/
public String getDueDate() {
return dueDate;
}
/**
* Getting the copyID of a particular copy of a resource
* @return copyID
*/
public int getCopyID() {
return copyID;
}
/**
* Getting the detail of a book
* @return book
*/
public Book getBook() {
return book;
}
/**
* Getting the detail of a DVD
* @return dvd
*/
public DVD getDVD() {
return dvd;
}
/**
* Getting the detail of a laptop
* @return laptop
*/
public Laptop getLaptop() {
return laptop;
}
/**
* Setting the duration that the copy of the resource is loaned for
* @param loanDuration
*/
public void setLoanDuration(String loanDuration) {
this.loanDuration = loanDuration;
}
/**
* Setting the date on which the copy of the resource needs to be returned to library
* @param dueDate
*/
public void setDueDate(String dueDate) {
this.dueDate = dueDate;
}
/**
* Setting the copyID of a particular copy of a resource
* @param copyID
*/
public void setCopyID() {
if (this.book != null) {
this.copyID = ++this.book.uniqueCopyID;
} else if (this.dvd != null) {
this.copyID = ++this.dvd.uniqueCopyID;
} else if (this.laptop != null) {
this.copyID = ++this.laptop.uniqueCopyID;
}
}
/**
* Setting the detail of a book
* @param book
*/
public void setBook(Book book) {
this.book = book;
}
/**
* Setting the detail of a dvd
* @param dvd
*/
public void setDVD(DVD dvd) {
this.dvd = dvd;
}
/**
* Setting the detail of a laptop
* @param laptop
*/
public void setLaptop(Laptop laptop) {
this.laptop = laptop;
}
/**
* @return the available
*/
public boolean getAvailable() {
return this.available;
}
/**
* @param available the available to set
*/
public void setAvailable(boolean newValue) {
this.available = newValue;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
}