001package edu.pdx.cs410J.grader;
002
003import java.util.ArrayList;
004import java.util.Collections;
005import java.util.LinkedHashMap;
006import java.util.List;
007
008public class SurveyResponsesFromD2L {
009  private LinkedHashMap<String, List<String>> questionsAndResponses = new LinkedHashMap<>();
010
011  public Iterable<String> getResponsesTo(String question) {
012    return questionsAndResponses.getOrDefault(question, Collections.emptyList());
013  }
014
015  public void noteQuestionAndResponse(String question, String response) {
016    List<String> responses = this.questionsAndResponses.get(question);
017    if (responses == null) {
018      responses = new ArrayList<>();
019      this.questionsAndResponses.put(question, responses);
020    }
021
022    responses.add(response);
023  }
024
025  public Iterable<String> getQuestions() {
026    return this.questionsAndResponses.keySet();
027  }
028}