August 2018
Intermediate to advanced
524 pages
14h 45m
English
We have already started the listing of the MastermindHandler class and, since this class is more than a hundred lines, I will not include it here as a whole. The most important method of this class is handle:
public void handle(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
Game game = buildGameFromRequest(request);
Guess newGuess = guesser.guess();
response.setContentType("text/html");
PrintWriter out = response.getWriter();
if (game.isFinished() || newGuess == Guess.none) {
displayGameOver(out);
} else {
log.debug("Adding new guess {} to the game", newGuess);
game.addGuess(newGuess, 0, 0);
displayGame(out);
}
bodyEnd(out);
}
We perform three steps. Step 1 is creating ...
Read now
Unlock full access