Assignment 7
Fourth-years: Due before class on Wednesday, June 3rd
For everyone else, before class on Friday, June 5th
- List three features of Java that support object-oriented programming
and describe how they do so.
- Write an applet that enables users to draw different shapes. Your applet
should allow users to choose from:
- Three different shapes (You can pick the sizes, but you can get an extra 2
points if users can specify the location and size by clicking and dragging the
mouse.)
- Eight different colors (A 2-point bonus if the user can choose any
of the 16,777,216 possible colors.)
- Filled or unfilled shapes
It's your job to design the interface, and your answer should include not only
the code for the applet but a brief (one or two paragraphs) description of why
you made the choices you did. (Here's a tip: Most users would want a 'clear canvas'
button.)
- Write an applet which plays the game "Rock, scissors, paper". The applet should
display three buttons: rock, scissors and paper. The user should click on a button
to choose and then the applet should choose at random for itself. The rules are:
- Rock crushes scissors
- Scissors cut paper
- Paper covers rock
The applet should print out the winner of each game, as well as the total games won
by the player, and the player's winning percentage (games won/total games).
(If your code runs as both an applet and an application, it's worth an extra 2 points.)
- Write an applet that enables users to order food for delivery over the Web
(the order's over the Web, not the food delivery). Your order applet should offer
breakfast, lunch and dinner, but only one meal's items should be visible at a time.
(For example, if the user chooses lunch, she should only see the lunch menu,
not breakfast or dinner.)
For 3 bonus points, display a dialog box that asks "Do you want fries with that?", if
the meal is lunch or dinner and the user didn't ask for fries.
- Write an applet that lets users enter text in a field in a choice of fonts, colors
and font sizes. If the user changes one of these, the current text (in addition to newly
entered text) should be displayed in the new font/color/size combination.
- Exercise 11.14 (which builds on Exercise 11.13).