PART 1 — Animation
The goal of this part of the assignment is to use a Graphics object to create a custom animation.
To get started, follow these instructions:
In Eclipse, import the archive file assign4.zip into your project.
Right-click on the src folder.
Choose General ? Archive File and click Next.
Browse to find the location where you downloaded assign4.zip and click Finish.
This should create a new package called assign4 that contains three files: Animation.java, AnimationWindow.java, and DrawingArea.java.
Run the AnimationWindow class. Click the Start button. You will see an animated house move across the screen while changing color. You can stop the animation by clicking the Stop button.
Your assignment is to create a more interesting animation.
At a minimum, you must create an animation that achieves the following.
Lasts at least ten seconds.
Is interesting. (Try to amuse and entertain the TAs. We will demo the best animations in class.)
Has multiple items moving in different directions at the same time.
Has an item that changes direction.
Has an item that changes color.
Has an item that expands, shrinks, or (even better) explodes.
To accomplish this, you will need to replace the implementation of the paintFrame method in the Animation class. You do not need to understand or even read the other two classes, unless you are interested. DO NOT modify the two other classes in any way. Note that the paintFrame method has two parameters:
a Graphics object (on which you can draw, using its methods)
the number of milliseconds that have passed since the animation started
You can make this substantial task easier by creating helper methods and calling them from paintFrame. For example, if you have two items that move independently, you might want to have one method to draw the first item and another method to draw the second item. You are strongly encouraged to use this strategy — helper methods reduce the time you spend programming and make your code easy to read
An animation is made up of many different frames. Each frame is a static image. The illusion of motion occurs because the images are displayed in rapid succession. ThepaintFrame method is called over and over again to obtain a sequence of static images. You can use the second parameter to determine how long the animation has been running, which will let you control the timing of visual effects.
Ensure that you have used meaningful variables names, consistent indentation/spacing, and appropriate comments. Overall, your paintFrame method should have good programming style.
Export your Animation.java file and submit it using the button below. DO NOT submit AnimationWindow.java or DrawingArea.java.
PART 2 — File Analysis
The goal of this part of the assignment is to create an application for analyzing text documents.
To get started, follow these instructions:
Download several books as plain text (i.e., .txt files), which you will use to test your application. A good place to find free books is Project Gutenberg.
Choose a variety books that have “Plain Text UTF-8” file downloads. Download them and save them in a convenient location as .txt files. You do not have to read the books.
The course staff will use their own book files for grading. Do not submit your downloaded files. Your application must work on any .txt documents of reasonable size, not just one or two specific books.
To your assign4 package created in Part 1, add a new class called TextAnalysis.
In your TextAnalysis class, construct an application that behaves as described below.
The user starts the application. The application displays a dialog box that askes the user to enter a word to search for in a book. (The user should enter a single word, but your application does not need to enforce this.) If the user cancels the dialog, the application quietly terminates. Otherwise, the user’s input is converted to lowercase and is used as the target word later in the application.
Next, the application displays a JFileChooser and allows the user to choose a file. (The user should choose some kind of text file, but your application does not need to enforce this.) If the user cancels the dialog, the application quietly terminates. Otherwise, the user’s selection is saved as the file to be processed later in the application.
The application opens the text file and reads it one word at a time. (A word is any sequence of symbols separated by whitespace. The next method of theScanner class correctly reads the next word.) Each word should be converted to lowercase as it is read. As it reads the words, the application collects the information needed to compute the following information.
The number of times the user’s target word occurs in the file.
The average length of all the words in the file. (This will be a decimal number, not an integer.)
The word that would come immediately before the user’s target word if all the distinct words in the file were arranged in lexicographic order. (If there is no such word, return the user’s word.) You must do this without actually putting the words into lexicographic order.
The word that would come immediately after the user’s target word if all the distinct words in the file were arranged in lexicographic order. (If there is no such word, return the user’s word.) You must do this without actually putting the words into lexicographic order.
Any other interesting statistic (of your choice) that involves both the target word and the words in the file.
The application reports the above statistics using a dialog message box.
Your application must adhere to the following guidelines.
Your dialog boxes must be user friendly in all circumstances. Use full English sentences with correct grammar and punctuation. Break each line as appropriate. Make sure null strings are never displayed. (Your application should communicate clearly with the user.)
Your application must not throw any exceptions under any circumstance. Exceptions are printed using red text in the console window. One common exception occurs when you attempt to use null strings or objects.
Do not read input or print results to the console. You must use popup dialog boxes.
You may assume the file the user selects contains at least one word.
Test your application thoroughly to make certain that it will work correctly for all plain text files.
Ensure that you have used meaningful variables names, consistent indentation/spacing, and appropriate comments. The class and all methods should be commented using Javadoc. Use additional comments, as needed. Overall, your program should have good programming style.
Export your TextAnalysis.java file and submit it using the button below.
NOTE: There are many, many different ways to solve this assignment. It is expected that every student’s solution will be unique. Feel free to explore interesting coding ideas or clever approaches. However, you must ensure that your finished application performs exactly as required