All pastes #420644 Raw Edit

Anonymous

public java v1 · immutable
·published 2007-04-02 09:32 UTC
rendered paste body
import java.io.*;import java.net.*;class BankServer{	public static void main(String[] args) throws IOException	{		final int PORT = 12345;				//Prepare the input and output streams in order to exchange info with the client				ObjectOutputStream outputToClient;		ObjectInputStream inputFromClient;				//The server needs to listen to a port before any connection can be 		//established				ServerSocket serverSocket = new ServerSocket(PORT);		//System.out.println("Server is listening to port " + PORT);				//After listening to a port, the server also needs to constantly		//be listening for a connection from a client		Socket connectToClient = serverSocket.accept();				//Create data input and output streams		outputToClient = new ObjectOutputStream(connectToClient.getOutputStream());		inputFromClient = new ObjectInputStream(connectToClient.getInputStream());				while(true)		{			try			{				String question = (String) inputFromClient.readObject();				System.out.println("Waiting for clients to connect....");				System.out.println("Received: " + question);				if(question.equals("quit"))  //added 				{					break;				}								Bank bank = Bank.getInstance();								// create new customer with checking account, balance 0    			Customer c1 = new Customer("Kellie","Smith");    			CheckingAccount ca1 = new CheckingAccount(c1, 0.0);    			bank.addAccount(ca1);    			// create new customer with saving account, balance 0    			Customer c2 = new Customer("Tom","Brown");    			SavingAccount sa1 = new SavingAccount(c2, 0.0);    			bank.addAccount(sa1);    			// create advisors    			Advisor a1 = new Advisor("Main","Howard");    			Advisor a2 = new Advisor("Fisher","Games");    														//BankService b1 = new BankService(s1);				//String answer = b1.executeCommand(question);										}catch(Exception ex){};					}	}}