lab16
subdirectory of your personal repo, the other submits a file report.txt
in the lab16
subdirectory of your personal repo.lab16
:
cd cs151 unzip ~/Downloads/play-java.zip mv play-java lab16
cd lab16 ./sbt run
localhost:9000
. You should see a welcome screen. Hit Ctrl+C when done.project/plugins.sbt
and add the line
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")after the other
addSbtPlugin
commands./sbt eclipsein the
lab16
directorylab16
directory. It will be called play-java
in Eclipse../sbt run
in a terminal window.http://localhost:9000/select/lesson16q1/CTo do that, you need to
conf/routes
fileHomeController
class:
public Result select(String problem, String choice) { return ok("You selected " + choice + " for " + problem + "\n").as("text/plain"); }
http://localhost:9000/select/lesson16q1/C
. What happens?conf/routes
so that your method gets called. What did you do?http://localhost:9000/select/lesson16q1/C
HomeController
:
private static HashMap<String, HashMap<String, Integer>> results = new HashMap<>();In the
select
method, add this code before the return
statement:
if (results.get(problem) == null) results.put(problem, new HashMap<>()); if (results.get(problem).get(choice) == null) results.get(problem).put(choice, 0); results.get(problem).put(choice, results.get(problem).get(choice) + 1);What does the code do?
public Result view(String problem)
that yields the map of counts for the given problem. Just turn the map results.get(problem)
into a string. What is your method?http://localhost:9000/select/lesson16q1/C http://localhost:9000/select/lesson16q1/A http://localhost:9000/select/lesson16q1/B http://localhost:9000/select/lesson16q1/C http://localhost:9000/view/lesson16q1What happens?