-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioBook.java
More file actions
29 lines (23 loc) · 768 Bytes
/
AudioBook.java
File metadata and controls
29 lines (23 loc) · 768 Bytes
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
public class AudioBook extends Book {
private int runTime;
AudioBook(String title, String author, int pageCount, int price, int runTime) {
super(title, author, 0, price);
this.runTime = runTime;
}
// overriding same method in parent book but in different way(polymorphism)
public void generalInfo() {
System.out.println("This is an audio book");
}
// Also overrloading method (polymorphism)
public void generalInfo(int publishedTime) {
for (int i = 0; i < publishedTime; i++) {
System.out.println("This is an audio book");
}
}
public int getRunTime() {
return this.runTime;
}
public void setRunTime(int runTime) {
this.runTime = runTime;
}
}