Assignment 7

Fourth-years: Due before class on Wednesday, June 3rd
For everyone else, before class on Friday, June 5th

  1. List three features of Java that support object-oriented programming and describe how they do so.
  2. Write an applet that enables users to draw different shapes. Your applet should allow users to choose from: 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.)
  3. 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: 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.)
  4. 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.
  5. 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.
  6. Exercise 11.14 (which builds on Exercise 11.13).