Data Structures and Algorithms — Homework 7

Due by 11:59pm Wednesday, March 20

Reading

Programming Exercises

  1. Finish exercise 8 from Lab 7, which asks you to create a new version of your fish-drawing class that implements the MovingImage interface and works with the Aquarium code. Call your new class YourNameFish2.

  2. Finish the MyDraw program (exercises 16 and 17) from Lab 7.


EXTRA CREDIT PROBLEM

You should finish your other programs first before working on this one.

  1. If you're feeling ambitious, design a GUI program called Calculator that simulates an old-school scientific calculator. The top level frame should be divided into two panels: one for the calculator's display (represented as a JTextField) and one for the buttons. The top level frame should use a BorderLayout, with the display at the North and the buttons at the Center, and the button panel should use a GridLayout. Include buttons for the arithmetic functions +, −, ×, ÷, =, and Clear. You can use the getText() method to retrieve the contents of a JTextField, and then convert it to a number using the Double.parseDouble(String) method. You could also include buttons for more advanced functions such as sin, cos, tan, sqrt, log, ex, and yx. For the trigonometric functions, you could also include a pair of mutually-exclusive radio buttons for switching between Degrees or Radians mode. You are free to make your calculator as fancy as you like. For example, your calculator might look something like the following:



Turning in Your Homework

Files to submit:

Submit the above files using the Homework Upload Site. Please include your name and the assignment number in a comment at the top of each Java source code file. You DO NOT need to submit your compiled .class files or any other files.

If you have questions about anything, just ask!