Commit cd86e5fd authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Tidying up formatting of daily advice code

parent 3e83df1e
Loading
Loading
Loading
Loading
+4 −3
Changes for src/main/java/ch15/DailyAdviceClient.java: 4 added lines, 3 removed lines.
Original line number Diff line number Diff line
package ch15;

import java.io.*;
import java.net.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class DailyAdviceClient {

@@ -16,7 +18,6 @@ public class DailyAdviceClient {
      System.out.println("Today you should: " + advice);

      reader.close();

    } catch (IOException ex) {
      ex.printStackTrace();
    }
+2 −7
Changes for src/main/java/ch15/DailyAdviceServer.java: 2 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -14,13 +14,9 @@ public class DailyAdviceServer {
          "You might want to rethink that haircut."};

  public void go() {

    try {
      ServerSocket serverSock = new ServerSocket(4242);


      while (true) {

        Socket sock = serverSock.accept();

        PrintWriter writer = new PrintWriter(sock.getOutputStream());
@@ -33,11 +29,10 @@ public class DailyAdviceServer {
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  } // close go
  }

  private String getAdvice() {
    int random = (int) (Math.random() * adviceList.length);
    return adviceList[random];
    return adviceList[(int) (Math.random() * adviceList.length)];
  }

  public static void main(String[] args) {