C SC 160 Project 2: The Adding Machine
10 points
Due: October 14
This is an individual assignment
For this lab project, you are to implement the Accumulator class that maintains
the internal state of an Adding Machine application.
You are given the Accumulator class specification, which is documented
at a linked web page. It remains for you to
write the Accumulator class, implementing the methods according to the
specification and defining
the needed instance variables. The remainder of the application, including the
GUI, is provided. The GUI is shown below:
The application, while resembling a calculator, represents an adding machine in
which a number is entered on the keypad one digit at a time, and then either added
to or subtracted from a running total. The running total is displayed after each
new number is accumulated into the sum. The clear button causes the running total
to be zeroed as well as any number that has been entered but not yet accumulated.
Getting Started
Four Java files are needed to make the adding machine work:
- AddingMain.java, which contains the main()method to kick
off the festivities. Provided.
- CloseableFrame.java, which provides a JFrame class capable of being closed. Provided.
- AddingFrame.java, a CloseableFrame subclass that implements the GUI. Provided.
- Accumulator.java, which implements the workings of the machine. You will write this.
The first three classes are provided in public repository folder Project2. Update public to get it. Then copy this folder
into your myFiles repository folder, then open Project2 and delete its .svn
folder if it has one (it should not).
Organize your work using a jGRASP project. After launching jGRASP, do this:
- Browse to the Project2 folder that you just copied into your account.
- From the File menu, select New then Java. A blank window opens in the editing
area.
- In the editing window, type public class Accumulator { } then save it as Accumulator.java
- Now create a project called AddingMachine and add the four
Java files to it.
- Open the file AddingMain.java for editing. Then go to
the Build menu and select Project's Main File > Set to Current File. Then close the file. You can subsequently run the application while
editing any of the project files. The only file you will edit is Accumulator.java
- You will not be able to run the application until you have "stubbed in" the required Accumulator
methods. This means to write skeleton versions of the methods so the class will compile. Methods must include
any required parameters, and return some dummy value such as 0 if a return is required.
Point Allocations
Points | Item |
2 |
Implementation of Accumulator() |
3 |
Implementation of addDigit() |
4 | One point each for implementation of plus(), minus(),
clear() and getDisplay() |
1 | Basic documentation. Comment containing your name, comments at the top of the
class and for each method. |
2 | Extra Credit. Javadoc-style comments for the class and each method, to produce the equivalent of
API handout. See textbook Section 7.7 (pp 397-401) for details and examples.
Preview in jGRASP with open-book icon (left of +). Not required. |
To Turn In
When you are finished, make sure everything is in your myFiles folder then commit it to the repository.
[ CSC 160 schedule
| C
SC 160 | Peter
Sanderson | Math Sciences server
| Math Sciences home page
| Otterbein ]
Last updated:
Peter Sanderson (PSanderson@otterbein.edu)