.jar
files We are trying to create a desktop application that has the look and feel of http://www.online- calculator.com. If you hit that URL, and try checking the source, you will find that this particular calculator is implemented in Flash, which has basically taken over where applets left off (that is a horribly condensed version of the history of UI).
You will notice that "clear" does not appear as a button in the online version. I did not like that. So I want you to just make that into a button. In particular your final calculator looks like:
Imagine you have a client out there who does not know programming. They see the online version linked to above. They like it but they hate the fact that they have to be connected to internet and connected to the internet on a device that has supports Flash. Hence their demand for a desktop application.
Create a project Calculator
, and within that a package calculator
. All your classes will go into this package.
CalculatorChip
. abstract String onClick(ActionEvent e)
method.C
/AC
(Clear/All Clear) -- notice that the text on this button may change. setOpaque(true)
method. main
method that creates an instance of Calculator
, calls a createGUI
method, and makes the result visible to the user. It also creates an instance of CalculatorChip
.
createGUI
method call smaller
methods, for example, createNumberButtons
, createMemoryButtons
, createOperationButtons
. Think about the different
regions of the calculator and the different layouts you have to use.ActionListener
to handle all ten of the digit buttons (0
to 9
). For the non-digit buttons, you can have a separate Listener for each (or combine them in various ways, if you prefer). This class should have the following methods, each of which displays a string to be shown in the calculator display (JTextField
). The string should not contain any whitespace.
String clear()
String memClear()
, String memRead()
, String memPlus()
, String memMinus()
String digit(int digit)
, where digit is a number from 0 to 9. String decimalPoint()
String add()
, String subtract()
, String multiply()
, String divide()
, String equals()
.String sqrt()
, String percent()
, String invert()
, String changeSign()
. You should try to make your calculator behave as much like the online calculator as possible. You probably think you know how a calculator behaves, but do you really? For example, can you predict the result of
?
Save your complete program, including source code, in an executable .jar
file. Eclipse can create this file for you--select your project in the Package explorer, Export your project to a Java → jar file
, and step through the menus selecting Next> until you can choose Calculator
as your Main class. If Java is installed correctly on your computer, double-clicking this jar file will run your calculator.
Zip up your project and submit to Canvas by 6am next Friday, November 22.