CS1321L Homework 3
Due: Monday, September 12 at 8:00 pm

Introduction

In this homework, you will work with the String class to better familiarize yourself with it. You also will do more with applets and graphcis, utilizing the Random class to help in the second part.

On the last HW assignment, you began to learn about javadoc. As you'll recall, Javadoc is an application that is part of the JDK that you downloaded. You can run it on the command line by typing "javadoc *.java" which will create documentation for all the classes in your current directory. If you are using JGrasp, you can invoke javadoc by using Project->Generate Documentation from the pull-down menu. Javadoc creates the nice web-page based documentation that we have been using in class (the API). Remember from class we said that javadoc comments were a special form of comment. Javadoc recognizes a comment that starts with /** as a javadoc comment. You should continue to use Javadoc comments on this assignment.

Assignment 3.1: I'd Like to Buy a Vowel

In this assignment, you should write an application that takes a line of input from the user, replaces all vowels in the line by asterisks, and then prints the result. Your program should first prompt the user and request that s/he enter a line of text. From there, you should do the work necessary to replace all voewls (a, e, i, o, u) by * and then print the result to the terminal. So, for instance, if the user enters
       Hello, my name is John
your program should print out
       H*ll*, my n*m* *s J*hn

Extra credit will be given if you can get Pat Sajak and Vanna White to visit class.

Assignment 3.2: Random Circles

Write a java applet that creates a window with a black background. Inside the window should be three circles. The first circle (color white) should be directly in the center of the window with radius 50. The second circle (color yellow) should be at a random position in the window and should have a radius that is a random size with value between 20 and 50. Directly in the center of that circle should be written the actual radius size (in black). The third circle (color cyan) should also be at a random position but it should have radius 50. Just to the bottom left of the circle you should write (in white) the x,y coordinates of the center of the circle. Although it may not be the best style (as we'll learn later) place all your code in the paint() method. Your program should also flexibly work with different size applet windows, that is, it shouldn't be hard-wired for a particular size window. Below is a sample view that your program should look like.

When you first write the program and get it working, use the same random number seed when you initialize the random number generator (value doesn't matter). Try iconifying the window such as moving it ot the task bar, then bring it back. What happens?

Next, use a varying seed to the random number generator. Recall that in class we discussed using System.currentTimeMillis() to get a varying long integer. Try the experiment with iconifying the window and bringing it back. Now what happens? Did something change? If so, why? Think about what is happening. Now try moving another window in front of your applet window. What happens?

When you turn in your code, submit this final version. Also, create a simple HTML web page that displays this applet.

Hint: When you position and size your circles, think carefully about the values of the parameters to the drawing routine. You may have to adjust carefully. Remember that radius and diameter are different! :^) Also, for making your applet flexible to different size windows, the routines getWidth() and getHeight() may be helpful. When called in the paint method, they will return the relative dimensions of the applet window.

Turn-in Procedures

After you have finished the above assignments, turn them via Webwork You will be submitting three files. Please make sure they are named as shown below:

  • VowelRemover.java
  • RandomCircles.java
  • RandomCircles.html (the html file you created for viewing your applet)