public class TVNewsStory extends NewsStory
A TVNewsStory
is composed of the date the story was broadcast,
the name of the TV news show that broadcast the story, the length the story
in seconds, the topic of the story, and two lead news makers in the story.
Since all of these elements are present in NewsStory
,
TVNewsStory
is created as a subclass of NewsStory
.
However, TVNewsStory
can implement getLengthInWords
because we know the inherent length measurement units for TV news stories
(seconds), whereas different news stories may use different length units.
Constructor and Description |
---|
TVNewsStory(java.time.LocalDate date,
java.lang.String sourceName,
int length,
java.lang.String topic,
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, getTopic
public TVNewsStory(java.time.LocalDate date, java.lang.String sourceName, int length, java.lang.String topic, 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 in seconds.topic
- The broad topic 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 TV news stories are
seconds, we need to convert the value we get from getLength
.
The design says we should use the conversion factor of 150 words per
minute. (Of course, a minute is 60 seconds, so this is a conversion
factor of 150/60.)
getLengthInWords
in class NewsStory
NewsStory.getLengthInWords()