Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- /**
- * The DisplayDocuments class is responsible for displaying tests and surveys
- * to the console screen for selecting and viewing.
- * @author Tom Rottinger
- *
- */
- public class DisplayDocuments {
- /**
- * displaySurveys does exactly what its name entails - it provides the
- * user with a list of surveys that are able to be displayed and, upon
- * user selection, displays the survey.
- * @throws IOException - in case of any bad input.
- */
- public static void displaySurveys() throws IOException
- {
- /** The selected survey, displayed at the end of the method. */
- Survey selectedSurvey;
- /** The reader used to get user input on which survey to display. */
- BufferedReader displayReader;
- /** The number indicating which survey the user selected. */
- int userSurveyChoice;
- /** User input, parsed into a number for selecting a survey. */
- String displayReaderEntry;
- displayReader = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Which survey would you like to display?");
- /** Display all surveys in memory. */
- for (int i = 1; i <= SurveyTestSystem.surveyList.size(); i++)
- {
- System.out.println(i + ".) " + SurveyTestSystem.surveyList.get(i-1).documentName);
- }
- /** Until a valid input is chosen, always wait for a valid input... */
- while (true)
- {
- displayReaderEntry = displayReader.readLine();
- try
- {
- userSurveyChoice = Integer.parseInt(displayReaderEntry);
- if (userSurveyChoice < 1 || userSurveyChoice > SurveyTestSystem.surveyList.size())
- {
- System.out.println("Please select a number from the list above.");
- }
- else break;
- }
- catch (Exception e)
- {
- }
- }
- /** Finally, display the selected survey. */
- selectedSurvey = SurveyTestSystem.surveyList.get(userSurveyChoice - 1);
- selectedSurvey.display();
- }
- public static void displayTests()
- {
- System.out.println("Feature coming soon!");
- }
- }
Add Comment
Please, Sign In to add comment