class UserInterface
extends java.lang.Object
This class provided helper methods to interact with the user.
Note that all methods in this class are static because we don't need to make
several UserInterface
objects and have them maintain their own
data. Instead, we simply need a collection of useful methods to create
windows that pop up one at a time, are used, and then are discarded.
Constructor and Description |
---|
UserInterface() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
convertToOutputFormat(NewspaperStory newspaperStory)
This method converts an individual story to the desired display format.
|
static java.lang.String |
createListOfNewspaperStoriesForNewsmaker(NewsMaker newsMaker)
This method takes a news maker and turns its list of newspaper stories
into a string formated for display to the user.
|
static void |
presentNewspaperStories(java.lang.String listOfStories,
java.lang.String newsMakerName)
This method displays the list of newspaper stories to the user using a
JOptionPane . |
static java.lang.String |
queryNewsMakerName()
This method asks the user for the name of a news maker using a
JOptionPane and returns it. |
static void |
reportNewsmakerNotFound(NewsMaker queriedNewsMaker) |
public static java.lang.String queryNewsMakerName()
JOptionPane
and returns it.public static java.lang.String createListOfNewspaperStoriesForNewsmaker(NewsMaker newsMaker)
newsMaker
- The news maker for which to create the story list as a stringprivate static java.lang.String convertToOutputFormat(NewspaperStory newspaperStory)
newspaperStory
- The story to convert to the display format.public static void presentNewspaperStories(java.lang.String listOfStories, java.lang.String newsMakerName)
JOptionPane
.
Note that a JOptionPane
works fine for small messages but
isn't suitable for large messages, such as those that can be generated
for news makers for whom there are many stories. However, to keep this
project relatively simple, we have gone with a JOptionPane
here. We'll learn how to develop more suitable graphical user interfaces
in later assignments.
listOfStories
- The list of stories to display, all as one (potentially very
large) String.newsMakerName
- The name of the news maker (which is put into the title of the
JOptionPane).public static void reportNewsmakerNotFound(NewsMaker queriedNewsMaker)