-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryItem.java
More file actions
48 lines (38 loc) · 1 KB
/
LibraryItem.java
File metadata and controls
48 lines (38 loc) · 1 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
import java.util.Date;
public class LibraryItem {
private int borrowCount;
public LibraryItem() {
borrowCount = 0;
}
public void checkout() {
borrowCount++;
System.out.println("Borrowed an item from the library.");
}
public int getBorrowCount() {
return borrowCount;
}
public static void main(String[] args) {
// Date today = new Date();
// System.out.println("Date: " + today);
// DVD cd1=new DVD();
// cd1.checkout();
LibraryItem l1=new LibraryItem();
l1.checkout();
}
}
class Book extends LibraryItem {
int daysToReturn = 14;
@Override
public void checkout() {
super.checkout();
System.out.println("Borrowed a book for " + daysToReturn + " days.");
}
}
class DVD extends LibraryItem {
int daysToReturn = 7;
@Override
public void checkout() {
super.checkout();
System.out.println("Borrowed a DVD for " + daysToReturn + " days.");
}
}