Now that you know everything about Java, you should be able to transform my ideas into classes and implementation of these classes (two different steps).
For that second exercise, I will still give you some directions by suggesting the organisation and interface of the classes, but you do not need to strictly follow that organisation as long as you get to a good result.
I would like to get a program that will open a window and show a jpeg, PNG or GIF picture in the middle of the frame.
The area of the frame should be four times the area of the picture so long as it remains equal to or less than half the area of your screen display. The dimension of the frame should be kept homothetic(*) to that of the picture.
If the picture is to big regarding these restrictions, it should be uniformly scaled down in order to fit the restrictions.
What restriction of that sort should be added here to be sure that nothing bad could happen running the program ?
Of course, the image will be initially drawn in the middle of the frame.
You could have a class, ShowImage, with three constructors :
some more tips online...
Eventually, the aim of the program will be to be able to drag the image around the JPanel via the mouse.
As well as showing...
There should be a text output (to the terminal) of the screen, frame and image dimensions, area and Width/Height ratios.
Write a little program that will get an integer as an argument and that will use recursion to compute factorial value of that integer. Try to find a graphical way to explain recursion
Input : 4
4! = 4 x 3!
= 4 x 3 x 2!
= 4 x 3 x 2 x 1! (recursion stops here because detection of the trivial case of 1!)
= 4 x 3 x 2
= 4 x 6
(*) Uniform Scaling (strectching or shrinking) possible from one to the other : go from one the other trough a homothetic transformation. A homothetic map preserves within a global scaling factor relative distances and angles.
|See the "Links" link above to find out the sources of the proposed informations
Pascal Vuylsteker / eScience / Computer Science / ANU
|Last modified: 20/4/2004
TOC - Print
|Send your comments at :