CS 112b
Spring 1999
Ileana Streinu
Midterm Exam
Part 2
Thursday, March 24, 1999 2:30 hours
Getting organized
- Send an email to Ileana when you get started. Specify what
time it is.
- Create a directory Midterm in your public_html directory,
with two subdirectories, Pb1 and Pb2.
- Create an html page called mid.html in Midterm, with links to two other
pages named pb1.html (in Pb1) and pb2.html (in Pb2). Make sure
the permissions are set up correctly.
- Work on Problem 1 in the directory Pb1 and on Problem 2 in
Pb2. The java files should NOT be readable during the two hours of
the exam.
- Before you leave the lab, please turn on the read permissions
on the java files.
- Send an email to Ileana and specify what time you have
finished the work.
Some advice on how to proceed
- The problems do NOT need sophisticated
solutions. Everything is a slight variation on what we did in
the labs and hwks during the first two weeks of the semester.
If
your code becomes too complex, ask me to make sure you have not
misunderstood the problem.
- To insure you get partial credit even
when the final program does not work as desired,
I recommend that you develop your applets in stages and
save the intermediate versions in separate directories when they
are finished and tested.
- Be generous with comments.
Part of the grade will be based on
how readable and neat your code is.
- In Problem 1, you will be asked to implement the solution that you have
designed for the
4th problem in the morning part of the exam, and add a simple
extra feature (draw the empty circle and filled circle with
different colors).
The
statement of the morning problem #4 will be repeated on this
handout.
The
myApplet.java template is available here for you
to copy.
- Problem 2 is a slight modification of a problem that you did in
one of the early homeworks.
Problem 1 (50 points)
The applet has two buttons and responds to mouse
clicks. The buttons are labeled Circle and Fill.
If the last button pressed on was Circle, the user can
draw an empty circle by click-and-drag. When the user presses the
Fill button, the last circle that was drawn on the screen is now
drawn as a filled circle.Then the
applet will not respond to mouse clicks for drawing circles
until the Circle button is pressed again.
In the beginning, the applet
behaves as if the Circle button has been pressed.
The applet draws only one circle at a time. It does not remember what the
user did in the past.
Each time the user draws a
new circle, the one that was there before will disappear.
Each time the circle button is pressed,
the old circle disappears from the screen.
The circle drawing is done by click and drag. The user clicks on a
point on the screen, then drags the mouse towards the bottom right part
of the screen and finally releases
the mouse. A circle is drawn at all these events.
The myApplet.java template.
Extra features to be added
- Draw the empty circle in black and the filled circle in red.
Problem 2 (50 points)
For this applet, the user clicks and drags with the mouse to draw
circles, as before. However, at any time all the
circles are redrawn, not just the last one.
Extra feature
(if you finished already, add this extra
feature for a bit of extra credit)
The circles are drawn
with alternating colors: the first one is black, the second is
red, then a next one is black again, then a red one follows, etc.
Last modified March 24, 1999.
Ileana Streinu