Chris Pollett>Old Classes>CS102, Spring 1999>Hw2

CS 102
HW#2

        Due on the web by 4pm, Thursday, Feb. 18, 1999. Read Chapter 11 in D&D, and read to page 97 in Bailey. Then make a subdirectory of your homepage directory called hw2 (make sure you have the case right). The command to do this is cd public_html<ret> mkdir hw2 <ret>. Put your source code for this homework here. Leave the modifications on your homework so that no one can read or execute it until you want to submit the homework. When you decided to submit move into your public_html directory and type chmod -R a+rx hw2<ret>. Then under your browser find the class page and click on the homework bot to get it to collect your homework. After doing this, again in your public_html directory, type: chmod 0700 hw2 <ret>.

  1. Write a simple drawing tool applet named Draw.java. This applet should have a menu bar from which the user can choose at least one of the following three actions: free-hand draw, line draw, and erase screen. Free-hand draw mode should be like program 10.21 in D&D. Line draw mode should allow you to select two points and let you draw in between them. See the window that pops up for an example.
  2. Consider the operations drawOval and fillOval. Using O-notation determine with an explanation that you put in file Explanation.txt, how time consuming these operation are as a function of the paramters supplied to them.
  3. Write an applet Add.java that takes as input from two textfields, two user supplied arbitrarily long numbers. Then when a submit button is pressed it prints out their sum. Since we have just discussed the Vector class, you must use this class when performing the addition. (Although it could be done directly with StringBuffer's) See below for how it should look
An applet for adding. An applet that pops up in its own window that can be used for drawing.