class NewspaperStory
extends java.lang.Object
A NewspaperStory
is composed of the date the story was
published, the name of the newspaper in which the story was published, the
count of words in the story, the topic for the story, and two lead news
makers in the story.
Modifier and Type | Field and Description |
---|---|
private java.time.LocalDate |
date
The date the story was published as a
java.time.LocalDate . |
private NewsMaker |
newsMaker1
The first news maker featured in the story.
|
private NewsMaker |
newsMaker2
The second news maker featured in the story.
|
private java.lang.String |
newspaperName
The name of the newspaper in which the story was published.
|
private java.lang.String |
topic
The broad topic of the story.
|
private int |
wordCount
The count of words in the story.
|
Constructor and Description |
---|
NewspaperStory(java.time.LocalDate date,
java.lang.String newspaperName,
int wordCount,
java.lang.String topic,
NewsMaker newsMaker1,
NewsMaker newsMaker2)
The constructor for the class which takes objects of appropriate types to
initialize all of the fields.
|
Modifier and Type | Method and Description |
---|---|
java.time.LocalDate |
getDate()
The accessor for the date field.
|
NewsMaker |
getNewsMaker1()
The accessor for the first news maker field.
|
NewsMaker |
getNewsMaker2()
The accessor for the second news maker field.
|
java.lang.String |
getNewspaperName()
The accessor for the newspaper name field.
|
java.lang.String |
getTopic()
The accessor for the topic field.
|
int |
getWordCount()
The accessor for the wordCount field.
|
private java.time.LocalDate date
java.time.LocalDate
.private java.lang.String newspaperName
private int wordCount
private java.lang.String topic
private NewsMaker newsMaker1
private NewsMaker newsMaker2
public NewspaperStory(java.time.LocalDate date, java.lang.String newspaperName, int wordCount, java.lang.String topic, NewsMaker newsMaker1, NewsMaker newsMaker2)
Note that in the world the count of words in a story cannot be negative, so our class should model that fact. However, to keep the project relatively simple, this requirement was not made in the project description and this check doesn't need to be made yet.
date
- The date the story was published as a java.time.LocalDate.newspaperName
- The name of the newspaper in which the story was published.wordCount
- The count of words in the story.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 java.time.LocalDate getDate()
Note that LocalDate
objects are immutable, so it is fine to
return the field itself.
public java.lang.String getNewspaperName()
Note that String
objects are immutable, so it is fine to
return the field itself.
public int getWordCount()
Note that int
s are passed by value, so it is fine to return
the field itself.
public java.lang.String getTopic()
Note that String
objects are immutable, so it is fine to
return the field itself.
public NewsMaker getNewsMaker1()
Note that NewsMaker
objects are mutable, so this really
should return a copy of the news maker instead. However, we haven't
studied that yet, so returning the news maker itself is acceptable for
now.
public NewsMaker getNewsMaker2()
Note that NewsMaker
objects are mutable, so this really
should return a copy of the news maker instead. However, we haven't
studied that yet, so returning the news maker itself is acceptable for
now.