In this homework, you will work with the String class to better familiarize yourself with it. You also will do more with applets and graphics, 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.
In this assignment, you should write an application called AccountBuilder that prompts for and reads the user's first name and last name (separately). Then print a string composed of the first letter of the user's first name, followed by (no more than) the first five characters of the user's last name, followed by a random number in the range 10 to 99. Similar algorithms are sometimes used to generate usernames for new computer accounts.
Write a java applet that creates a window with a black background. Inside the window should be two circles and a square. The first circle (color white) should be directly in the center of the window with radius 50. The second circle (color green) should also have a radius of 50, but it should be at a random position in the window. Just to the bottom left of the circle you should write (in white) the x,y coordinates of the center of the circle. The square (color orange) should be at a random position in the window and should have a side that is a random size with value between 25 and 75. Directly in the center of the square should be written the actual length of the side (in black). 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 and square, 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.
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: