Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
This first assignment is intended more as a warm-up exercise, to bring you back
up to speed on Java from last semester (or even arlier, for some of you). If
you find it especially difficult, see me: it may be that you are mis-interpreting
my intent, or that I can help in some other way, too.
The assignment is a little simulation of a windowing system: you will draw
some over-lapping rectangles on the screen, then allow the user to click on
them, bringing the selected window to the front (and re-drawing). In order
to make the drawings easier to interpret, you will show a number in the
upper-left-hand corner of each window, showing its place in the order, with
the top window labelled with a "1", the next labelled with a "2" and so on.
To get the original window data, you will read the lines of a file or a text
field (either way is OK with me, whichever you are more comfortable with).
Let's agree to put four positive integers per line, with the first two
representing the upper-left coordinate (x and y) of the window and the next
two its width and height), in the order x-y-w-h.
So your program should proceed as follows:
* phase 1: read in the window coordinate data and draw the windows;
* phase 2: take user clicks on the windows, bringing each selected
window to the front and leaving the others in the same relative order.
(Of course, some windows might remain completely obscured, and thus
not selectable, or even visible. Oh well.)
Regarding implementation:
* think in terms of classes: a window class, a point class, a rectangle
class; perhaps even a "collection of windows" class (call it a screen);
* you'll need to separate out integers on a line: you can use the
StringTokenizer class for this (and parseInt);
* if you use a text firld for initial input, you may want to de-activate
it after the first phase (i.e., once input is read).