public class NewspaperStory extends NewsStory
A NewspaperStory
is composed of the date the story was
published, the name of the newspaper where the story was published, the
length the story in words, the broad topic for the story, the specific
subject matter of the story, and two lead news makers in the story.
Since all of these elements are present in NewsStory
,
NewspaperStory
is created as a subclass of
NewsStory
. However, NewspaperStory
can implement
getLengthInWords
because we know the inherent length measurement
units for newspaper stories (words), whereas different news stories may use
different length units.
Constructor and Description |
---|
NewspaperStory(java.time.LocalDate date,
java.lang.String sourceName,
int length,
java.lang.String topic,
java.lang.String subject,
NewsMaker newsMaker1,
NewsMaker newsMaker2)
The constructor which takes parameters for all of the fields can simply
pass them to the constructor for
NewsStory and let it do the
work. |
Modifier and Type | Method and Description |
---|---|
int |
getLengthInWords()
Overrides the
getLengthInWords method from
NewsStory . |
compareTo, equals, getDate, getLength, getNewsMaker1, getNewsMaker2, getSource, getSubject, getTopic
public NewspaperStory(java.time.LocalDate date, java.lang.String sourceName, int length, java.lang.String topic, java.lang.String subject, NewsMaker newsMaker1, NewsMaker newsMaker2)
NewsStory
and let it do the
work.date
- The date the story was published as a java.time.LocalDate.sourceName
- The name of the source in which the story was published.length
- The length of the story.topic
- The broad topic of the story.subject
- The specific subject matter of the story.newsMaker1
- The first news maker featured in the story.newsMaker2
- The second news maker featured in the story.public int getLengthInWords()
getLengthInWords
method from
NewsStory
.
Because the inherent length measurement units for newspaper stories are
words, we can simply return the value we get from getLength
.
getLengthInWords
in class NewsStory
NewsStory.getLengthInWords()