|
|
|
|
Points: 50 What to turn in: Turn in a disk with all the answers to this assignment. Note that all files are to be put in their respective folders. That is, all files for lab x are to put in the folder A:\LABx, where x is the lab # and all files for assignment y are to be put in the folder A:\ASSIGNy, where y is the assignment #. For java applications, turn in the *.java and *.class files. For a question that involves an answer in simple text, turn in a *.txt file. For java applets, turn in the *.java, *.class, and *.html files. Note: When you turn in the last assignment (not now!), I need you to also turn in the solutions to all the other labs/assignments that you have done since the beginning of the semester. I will keep this disk for record keeping purposes. You ought to also duplicate this disk so that you have a record of all the things that you have done for future reference. [Simple Java I/O] 1. [10 pts] Using the template file printNames.java, write a Java program that prompts for 5 first names and echoes all the names that start with the character ‘J’ or 'j', have at least 4 characters, and end with "ny", "my", or "ly".
2. [20 pts] Create a class called ACSFaculty. The following are the fields and methods that the class is to support.
Fields
The driver for the above class is given in TestACSFaculty.java. Instructions:
It should have a background color that is other than yellow, white, black, red, blue, and green. It should compute the percentages of heads and tails and display them together with the number of heads and tails. Use the template given in the file CoinToss.java. You need to only provide a method called tossACoin to do the simulation. The rest of the applet has already been written for you. Of course, you need to change the background color as well (you should be able to locate this one line that sets the color). 5. [Bonus: 5 pts] Create an applet, call it DrawBox.java, that enables the user to draw a box in the applet space. The behaviors of the applet should resemble the one in DrawBox. (Hint: In the Graphics class, there is a drawRect method to draw a rectangle. Also, one of the mouse events that you can capture is mouseDragged.) Check out some of the examples given below to get a feel of event handling on mouse. http://www.itk.ilstu.edu/faculty/bllim/oo/MouseExampleonserver.html http://www.itk.ilstu.edu/faculty/bllim/oo/MouseExample.java http://www.itk.ilstu.edu/faculty/bllim/oo/EraseHDonServer.html http://www.itk.ilstu.edu/faculty/bllim/oo/EraseHD.java
|