01: import java.io.BufferedReader;
02: import java.io.InputStream;
03: import java.io.InputStreamReader;
04: import java.io.IOException;
05: import java.io.OutputStream;
06: import java.io.PrintWriter;
07: import java.net.Socket;
08: 
09: /**
10:    This program tests the bank server.
11: */
12: public class BankClient
13: {
14:    public static void main(String[] args) throws IOException
15:    {
16:       final int SBAP_PORT = 8888;
17:       Socket s = new Socket("localhost", SBAP_PORT);
18:       InputStream in = s.getInputStream();
19:       OutputStream out = s.getOutputStream();
20:       BufferedReader reader = new BufferedReader(
21:          new InputStreamReader(in));
22:       PrintWriter writer = new PrintWriter(out); 
23:       
24:       String command = "DEPOSIT 3 1000\n";
25:       System.out.print("Sending: " + command);
26:       writer.print(command);
27:       writer.flush();
28:       String response = reader.readLine();
29:       System.out.println("Receiving: " + response);
30:       
31:       command = "WITHDRAW 3 500\n";
32:       System.out.print("Sending: " + command);
33:       writer.print(command);
34:       writer.flush();
35:       response = reader.readLine();
36:       System.out.println("Receiving: " + response);
37:       
38:       command = "QUIT\n";
39:       System.out.print("Sending: " + command);
40:       writer.print(command);
41:       writer.flush();
42: 
43:       s.close();
44:    }
45: }
46: 
47: 
48: 
49: 
50: