Due: Thursday, April 20th at 10:40am
Rules: You may consult your notes, old work, the textbook, examples and sample solutions available at the CS202 web page, and the Java API documentation. You may not consult any other people.
Scoring: There are three problems. Each problem will be graded out of 100 points. The two problems you do best on will each be worth 40% of your grade for the exam. The problem you do worst on will account for the remaining 20%. Keep in mind that it may be more worthwhile for you to move on to a new problem than to spend too much time working out the final details of another.
Files: Files for all problems are in a Java archive. There is an updated version of Bomb.java (included in the current version of the archive).
Submissions: Submit the source code (.java files) for your solutions as attachments to e-mail. You should send five classes total (one each from Problems 1 and 2, and three from Problem 3 (Bomb, GuidedMissile, and Ordnance).
Problem 1: Complete the LX_P1 class so it opens a window for a speeding ticket writing program. The interface should look like the one shown below. When the user clicks on the "Warning" button, the program should display, using System.out.println a message like "You would have received a $100 ticket." When the user clicks the "Ticket" button, the program should display a message like "You received a $100 ticket." The fine shown in the messages should vary depending on the speed limit and recorded speed according to the formula ((speed - limit) / 5 + 1) * 50, and should be doubled if the "Work Zone" box is checked. The interface needn't look exactly like the one shown below, but ideally the labels won't take up more horizontal space than they need, and there shouldn't be much empty space in the interface.
Problem 2: Complete the LX_P2 class so it opens a file called "lx_p2_input.txt" (included in the jar file) that contains information about a sports memorabilia collection and outputs, using System.out.println, the total value of the collection. The data is given in a format like the following
10 3 2 1 0 1 $30 : 1987 Fleer Scottie Pippin 1 0 0 1 $10 : 1981 Topps Nolan Ryan 8 4 3 1 $20 : 1979 Topps Eddie Murray 2 2 $15 : 1986 Topps Bruce Smithwhere the first integer on each line is the quantity of an item and the number before the colon is the value of an item. None of the other information is relevant to the program. The total value of the collection is the sum of the product of the quantity of each item and the value of each item. For example, given the data shown above, the program should output a total value of 500. The program should display a short error message if it encounters any exception during execution. There should be, at the least, a separate message if the file does not exist, if there is some other I/O error while reading the file, and if there is a problem with the format of the data in the file.
Problem 3: Forward Base Psi is the prequel to Forward Base Omega. Forward Base Psi is under heavy bombardment by the Ceelons. The Ceelons are using two kinds of weapons: Bombs, and GuidedMissiles which are represented by the respective classes, which are subclasses of RectangularSprite. Refactor the Bomb and GuidedMissile classes so they are subclasses of a new class called Ordnance which is in turn a subclass of RectangularSprite. Full credit will be given only to solutions that leave only a minimal amount of code in the two subclasses.
To test your code, compile and run PsiWindow.