Commit 33b9845f authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15a] Changing Daily Advice Server again to fit better in the book

parent 48bc8c94
Loading
Loading
Loading
Loading
+3 −2
Changes for src/main/java/ch15/DailyAdviceServer.java: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ public class DailyAdviceServer {
          "One word: inappropriate",
          "Just for today, be honest. Tell your boss what you *really* think",
          "You might want to rethink that haircut."};
  private final Random randomGenerator = new Random();
  private final Random random = new Random();

  public void go() {
    try (ServerSocketChannel serverChannel = ServerSocketChannel.open()) {
@@ -33,7 +33,8 @@ public class DailyAdviceServer {
  }

  private String getAdvice() {
    return adviceList[randomGenerator.nextInt(adviceList.length)];
    int nextAdvice = random.nextInt(adviceList.length);
    return adviceList[nextAdvice];
  }

  public static void main(String[] args) {