-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNovel.java
More file actions
22 lines (19 loc) · 850 Bytes
/
Novel.java
File metadata and controls
22 lines (19 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Novel extends Book {
private final String genre; // The genre of the novel
// Constructor to initialize the novel's attributes
public Novel(String title, int numberOfPages, String publisher, String author, String[] primaryCharacters, String genre) {
super(title, numberOfPages, publisher, author, primaryCharacters);
this.genre = genre;
}
// Provides a description of the novel
@Override
public void describeMaterial() {
System.out.println("This is a novel of genre: " + genre + ".");
super.describeMaterial();
}
// Returns a string representation of the novel
@Override
public String toString() {
return "Novel [Title: " + title + ", Author: " + author + ", Genre: " + genre + ", Pages: " + numberOfPages + ", Publisher: " + publisher + "]";
}
}