CIS 180: Object-Oriented Programming
Homework #6

Adding Machine User Interface

Due Monday, October 31, 2011


The objectives of this homework are:

Problem Statement

For this project you are asked to design and implement an AddingMachine class that provides the user interface for a simple adding machine. The adding machine is like a calculator application, but only does addition. Your program only needs to display the user interface, and exit when the user clicks the window's close box. Next week you will add code to make the adding machine's buttons functional.

The user interface should contain twelve buttons: one for each digit 0-9, a "Clear" button, and an "Enter" button. There should also be a label that is used for the AddingMachine's display.

The AddingMachine's display value should be right justified along the top of the calculator. It should not change its height when the window is resized. Initially the number 0 is displayed. Check documentation to see how to get the text of a label right aligned. The twelve buttons should all have equal widths and heights and should fill the remainder of the AddingMachine window. The figures below show how the AddingMachine should look depending on the size and shape of the window:


Draw a UML class diagram of the AddingMachine class, showing all of the fields and methods, including their accessibility (public or private) and data types.


  1. Create a java project for your assignment and add an AddingMachine class.
  2. Code a comment block with your name and description of the AddingMachine class.
  3. Add the fields needed for the user interface items.
  4. Code a constructor that just arranges for the window's close box to cause the application to exit, sets the size of the window, and makes it visible.
  5. Code a main method to display the adding machine window, and test.
  6. Add the rest of the code to display the user interface in small increments and test frequently.

What to turn in

When your assignment is complete, add some comments to the comment block of the java source code explaining any problems you encountered in completing the assignment and describing any bugs in your solution.

Submit your source code ( as well as your class diagram as email attachments to your lab instructor. Alternatively, you may submit your class diagram in hardcopy. Use the subject line CIS-180 HW#6 in your email.

Make sure you send your homework to the proper place. Homework sent to the wrong address may not receive credit!

Lab SectionGraderEmail
L1 Mon. 2PM Wes Fowlks
L2 Wed. 9AM Neelima Mothe
L3 Wed. 1PM Wes Fowlks

There will be a 10% penalty for assignments received after the due date. Assignments will not be accepted more than one week past the due date.