The goal of this project is to review the basics of object-oriented programming and to give you an initial try at system design.
In this project you will make a program that emulates a 4-function calculator. This program will use a GUI; a window looking like a calculator will appear on the screen, and the user can manipulate it by clicking on the buttons.
I have made the "face" of the calculator already-- the GUI is given to you. You need to write the rest of the program, which will interact with the window.
After making the directory for this project, copy the following files from the course public directory:
cp /homeemp/tvandrun/pub/245/CalculatorFace.java . cp /homeemp/tvandrun/pub/245/ConcreteCalculatorFace.class . cp /homeemp/tvandrun/pub/245/ConcreteCalculatorFace\$1.class .
CalculatorFace
is an interface that defines
the method signatures for the object representing the
calculator window.
ConcreteCalculatorFace
is a class implementing
CalculatorFace
(I am not giving you the source code).
ConcreteCalculatorFace$1
is another class that
ConcreteCalculatorFace
makes use of.
As you can see from inspecting the code in
CalculatorFace.java
, the only interaction
with the window available to use is
You may either get the buttons all at once by means of an iterator
(for example, if you want to store them yourself somehow)
or can look them up by calling getButton
with the character that appears on the button.
(The buttons do not write to the screen by default; they do nothing without you writing something for it.)
You will have to write action listeners for the buttons.
If you have never used the ActionListener
class
(or other GUI components), read the relevant sections in the
textbook (from chapter 17), look at the Java API,
and ask for help if you want a fuller explanation or some
guidence in finding the relevant parts of the class.
(Please read the sections before asking for help...
but do not hesitate to ask.)
ConcreteCalculatorFace
has a constructor that
takes no parameters.
A window automaticallly appears.
Copy all the files you made or modified to a turn-in directory I've made for you.
cp
filename
/homeemp/tvandrun/turnin/245/
{jessica,sam,chet,jan}
DUE: Wednesday, Jan 31, 5:00 pm.