@@ -0,0 +1,2918 @@
+package Main;%0Aimport java.io.*;%0Aimport java.net.*;%0A/* %0AEnhanced and optimized for Moodfinder application by Amin Amini Maghsoud Bigy: 2012%0A*/%0Apublic class Worker %7B%0A%09 %09%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        // Set up the socket, in and out variables%0A        Socket Socket = null;%0A        PrintWriter out = null;%0A        BufferedReader in = null;%0A        boolean first_run = true;    %0A        try %7B%0A            Socket = new Socket(%22localhost%22, 4444);%0A            out = new PrintWriter(Socket.getOutputStream(), true);%0A            in = new BufferedReader(new InputStreamReader(Socket.getInputStream()));%0A        %7D catch (UnknownHostException e) %7B%0A            System.err.println(%22Don't know about host: localhost %22);%0A            System.exit(1);%0A        %7D catch (IOException e) %7B%0A            System.err.println(%22Couldn't get I/O for the connection to: 4444.%22);%0A            System.exit(1);%0A        %7D%0A        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));%0A        String fromServer;%0A        String fromUser;%0A        System.out.println(%22Initialised client and IO connections%22); %0A        /* Print out what the server says %0A         * Take the client's response and send it to the server */ %0A    %09%0A        while ((fromServer = in.readLine()) != null) %7B%0A            System.out.println(%22Server: %22 + fromServer);%0A            if (fromServer.equals(%22END%22)) %7B%0A            %09System.out.println(%22FINISHED%22);%0A            %09  out.close();%0A                  in.close();%0A                  stdIn.close();%0A                  Socket.close();%0A            %09break;%0A            %7D%0A            if (fromServer.contains(%22*%22))%0A            %7B%0A                String %5B%5D number_list = fromServer.split(%22%5C%5C*%22);%0A              //Convert the receiving numbers from Manager back into Integers%0A                int num1  = Integer.parseInt(number_list%5B0%5D);%0A                int num2 = Integer.parseInt(number_list%5B1%5D);%0A                //Multiply the numbers and put them into Client_total variable%0A                int Client_total = num1*num2;%0A         %09   System.out.println(%22Client answer =: %22 + Client_total); %0A         %09   out.println(Integer.toString(Client_total));  %0A            %7D else %7B%0A          if (first_run == true)%0A           %7B%0A            %09fromUser = stdIn.readLine();%0A                if (fromUser != null) %0A                %7B%0A                %09first_run = false;%0A                    System.out.println(%22Client: %22 + fromUser);%0A                    out.println(fromUser); %0A                %7D%0A            %7D %0A            else %7B%0A            fromUser = %22yes%22;%0A            if (fromUser != null) %0A            %7B%0A                System.out.println(%22Client: %22 + fromUser);%0A                out.println(fromUser);                          %0A            %7D        %0A            %7D    %0A        %7D%7D%0A       // Tidy up%0A        out.close();%0A        in.close();%0A        stdIn.close();%0A        Socket.close();%0A    %7D%0A%7D%0A

Create Worker.java