Lab 15

Readers and Writers for BankAccount Transactions over Sockets


Introduction

During Lab14, we looked at how we might "load" a BankAccount by reading transactions from a text file and then "saving" the BankAccount by writing it back out to a (different) text file. 

In class since Lab14 we have been talking about using sockets as a means of communicating over a network and the fact that sockets allow us to send entire an Object as long as it implements the "serializable" interface.

This week you are going to walk through an activity very similar to what you did last week in Lab 14 but this time taking advantage of Sockets.

To begin with you will need to download and unzip the following starter code

If you look at the code in this distribution you will see two sets of code. 

In order to avoid errors, you should compile the code in each directory by invoking "javac *.java" within each directory before beginning and from time to time as you make changes.


Tasks

Complete this object-oriented program by doing the following:

  1. Within the Client directory, write the BankAccountNetworkReader class. A BankAccountNetworkReader is an object that will read Transactions off of a socket connection to the server and save these into a BankAccount.

    The BankAccountNetworkReader class should provide:

    You will be running both the client and the server on your machine, so use InetAddress.getLocalHost() as the server value.

     

  2. Within the Client directory, write the BankAccountNetworkWriter class. A BankAccountNetworkWriter is an object that will read a local BankAccount and write its Transactions on a socket connection to the server

    The BankAccountNetworkWriter class should provide:

 

When you are ready to test this, open one window and run the Server (BankAccountServer) and open another window and run the Client (BankAccountClient).  Add two or three transactions to the BankAccount using the ATM window and then press the "write" button.  Open the file named "transactions2.txt" (located in the server directory). and verify that this file contains all of the transactions from the original file (transactions1.txt) plus the new ones you added using the ATM window.


Deliverables

Clean out all of the *.class and *.java~ files then zip all of these together into a single Lab15.zip file and submit via submission system.