CIT 591 Calculator Notes
Fall 2008, David Matuszek


As mentioned in lab, please use the following names:


Please just make copies of your BalancedTernary class and its JUnit test class, and add these classes to your BalancedTernaryCalculator project.

In normal usage (and according to the DRY principle) it would be better to leave these classes in their original package, and import them. However, the easiest way to submit this assignment is to simply zip up your project and turn it in--and if you do that, you may forget to turn in your earlier classes.

By the way, I should be able to replace your BalancedTernary class with my own. That means you should have followed the directions in the previous assignment exactly; your calculator should not use any additional methods, or methods with different signatures that those that were assigned.

JUnit testing

We have not talked about how to JUnit test GUIs (it is possible but not easy). No additional JUnit testing is expected or required.

If you are unsure of your own JUnit tests for the BalancedTernary class, you may use mine instead. Please include the JUnit tests--either yours or mine, I don't care which--when you turn in this assignment.

How the calculator should behave

As I said in the assignment, I would like the calculator to behave just like a cheap (under $5) calculator. It should be able to do simple calculations: 10 + 5 = should give 15 (in the balanced ternary equivalent, of course); and continued calculations: 10 + 5 - (calculator shows 15) 2 = should give 13.

The C (Clear) button should clear only the number in the display, but not any pending operation; for example, 10 + 12 C (calculator shows 0) 21 should give 31. The AC (All Clear) button should clear both the display and any pending operation.

The calculator, being very cheap, doesn't need to know about precedence of operations. For instance, 3 + 7 * 5 should give 50, not 38. Nor does the calculator have parentheses.

If the user enters something that doesn't make sense, for example 1 * =, your answer doesn't have to make sense, either. If you notice that the user has done something wrong, the best thing to do is to display Error (in the TextField), but even that isn't required. However, your program should not crash, regardless of what kind of garbage the user enters.

In addition to using the calculator buttons, you are supposed to be able to enter (and modify) numbers by typing directly into the calculator's display (the TextField). This is easy. However, you are also supposed to ignore (and not display) any illegal characters typed into that field. You may find this part quite challenging, and I recommend that you leave it to last.