<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>ATM Simulation Code</title></head><body>
<h2 align="center">ATM Simulation Code</h2>
<p>
When this example was first developed (in 1996), the implementation was done in C++,
using the curses package to produce a screen display that looks something like the
machine being modelled. More recently (1997), it has been re-implemented using Java,
with a full GUI interface. As noted in the initial page, minor changes were made to
the overall design at that time as well. Both implementations are based on the same
design, and except for the classes that model the components of the ATM, the code
in both is very similar - in fact, much of the Java code is a straight translation
of the corresponding C++ code. The following are the significant structural
differences (see also the discussion of data type/prototype issues on the
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/OperationDescription.html">Operation Description Forms page</a>):
</p><ol>
<li>
The Java constructor for class ATM has an additional parameter - a GUI container -
that is not documented in the Class/Operation description forms. It uses this
container to hold and display the various component parts of the ATM that it
constructs.
</li><li>
The C++ implementation of the machine components in atmparts.cc uses quite a
number of static variables plus an additional module (window.h/.cc) to simulate
the machine on the screen using the curses pacakge. Most of the classes in the
Java atmparts package have additional fields and methods needed to support the GUI
that are not documented on the Class/Operation description form pages. and there
are two additional classes in package (GUILayout, QuestionDialog) that contribute
to the task as well.
</li><li>
The class Money has a different implementation in the two languages. In the C++
version, the operators +, -, +=, -=, ==, and < are overloaded for Money. Since
operator overloading is not possible in Java, the Java version has methods named
add (two versions), subtract (two versions), equals, and less. Also, the Java
version has a set() method; in several places Money values are returned through the
parameters of a method, which is done by assigning to a reference parameter in
C++ and by setting the value of the object passed in Java.
</li></ol>
<p></p>
<p>
Both implementations make use of two classes in addition to those that were developed
during the early stages of the design. The need for these became evident when doing
the detailed design of the individual classes.
The class Money uses a class to implement money as an abstract
data type. The class Status encapsulates status codes that indicate success or
failure of various transactions. (This is basically an enum in C++, and a class that
consists of static final int's in Java.)
</p>
<p>
<a href="#C++%20Implementation">C++ Implementation</a>
<br>
<a href="#Java%20Implementation">Java Implementation</a>
</p>
<p>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/default.html">[ Intro ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/Requirements.html">[ Requirements ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/DomainObjects.html">[ Domain Objects ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/UseCases.html">[ Use Cases ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/SessionStateDiagram.html">[ State Diagram ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/TransInteractionDiagram.html">[ Interaction Diagram ]</a>
<br>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/CRCcards.html">[ CRC Cards ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/ClassDiagram.html">[ Class Diagram ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/ClassDescription.html">[ Class Desc. Forms ]</a>
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/OperationDescription.html">[ Operation Desc. Forms ]</a>
[ Code ]
<a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/Executable.html">[ Executable ]</a>
</p>
<h6>Copyright � 1996, 1997, 1998 - Russell C. Bjork. Permission for non-commercial
reproduction for educational use is hereby granted; all other rights are reserved.</h6>
<a name="C++ Implementation">
</a><h3 align="center"><a name="C++ Implementation">C++ Implementation</a></h3>
<p>
<a name="C++ Implementation">The implementation of the ATM simulation in C++ consists of eight modules that
declare and implement the various classes - most consisting of an interface (.h)
file that contains the class declaration(s) and an implementation (.cc) file that
implements the methods declared in the interface. (No implementation file is
needed for the class Status, and no interface file is needed for the main program.)
Most modules implement a single class, but all the component parts of the ATM
are grouped together into a single atmparts module, and all types of transactions are
grouped into a single transactions module.
</a></p>
<p>
<a name="C++ Implementation">The current version of these files has been compiled and run on both a VAX/VMS system
and a Linux system, both using gnu C++. A complete downloadable package of the all
the source code will eventually be available via anonymous ftp. The README file in
that package contains information about system specific details.
</a></p>
<h4 align="left"><a name="C++ Implementation">Files that Implement the Various Classes, Plus Main Program</a></h4>
<table width="100%">
<tbody><tr><th align="left" width="30%">Interface</th><th align="left" width="30%">Implementation</th>
<th align="left" width="40%">Purpose</th></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/atm.h.html">atm.h</a></td>
<td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/atm.cc.html">atm.cc</a></td><td>ATM itself</td></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/atmparts.h.html">atmparts.h</a></td>
<td><!--<a href="c++Code/html/atmparts.cc.html">-->atmparts.cc<!--</a>--></td>
<td>Component parts of ATM</td></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/session.h.html">session.h</a></td>
<td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/session.cc.html">session.cc</a></td><td>Perform a customer session</td></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/transaction.h.html">transaction.h</a></td>
<td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/transaction.cc.html">transaction.cc</a></td><td>Perform a transaction</td></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/bank.h.html">bank.h</a></td>
<td><!--<a href="c++Code/html/bank.cc.html">-->bank.cc<!--</a>--></td>
<td>Manage communication with bank</td></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/money.h.html">money.h</a></td>
<td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/money.cc.html">money.cc</a></td>
<td>Abstract data type Money</td></tr>
<tr><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/status.h.html">status.h</a></td><td>(None)</td>
<td>Status code values</td></tr>
<tr><td>(None)</td><td><a href="http://www.math-cs.gordon.edu/courses/cs320/ATM_Example/c++Code/html/main.cc.html">main.cc</a></td><td>Main program</td></tr>
</tbody></table>
<p>
<a name="C++ Implementation">NOTE: The implementation file atmparts.cc contains v