This shows you the differences between the selected revision and the current version of the page.
| courses:cs102-200903:assigns:assign5 2009/10/31 14:42 | courses:cs102-200903:assigns:assign5 2009/11/06 09:38 current | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| - | In this assignment, you will continue working on a game involving UFOs and anti-UFOs. You should download the following file, already adapted for use in NetBeans: {{courses:cs102-200903:assigns:animatedufoworld.java|AnimatedUFOWorld.java}}. //You should work on this assignment in NetBeans.// \\ \\ | + | In this assignment, you will continue working on a game involving UFOs and anti-UFOs. You may choose to download the following file, already adapted for use in NetBeans: {{courses:cs102-200903:assigns:animatedufoworld.java|AnimatedUFOWorld.java}}, or, for the brave-of-heart, use your own solution for Assignment 4 as a starting point. //You should work on this assignment in NetBeans.// \\ \\ |
| To download NetBeans (if you choose to work on your own computer), go to this website: {{http://www.netbeans.org/downloads/|NetBeans downloads}}. Choose the correct computer type in the drop down menu at the top right of the page. Then choose the Java SE download (first column). Follow the usual directions to download and install the package and ask for help installing the software from your professor or a coach if you need it. \\ \\ | To download NetBeans (if you choose to work on your own computer), go to this website: {{http://www.netbeans.org/downloads/|NetBeans downloads}}. Choose the correct computer type in the drop down menu at the top right of the page. Then choose the Java SE download (first column). Follow the usual directions to download and install the package and ask for help installing the software from your professor or a coach if you need it. \\ \\ | ||
| Line 44: | Line 44: | ||
| - | ==== B. Changing the move method of the UFOWorld and UFO classes ==== | ||
| - | From line 9 in the example code above, you can see that the move method in UFOWorld is now a void method. The examples at the bottom of page 413 show two options for writing the move method...the one on the lower left uses a void version of move in the UFO class and the one on the lower right uses an applicative version of move in the UFO class to return a new UFO object. Page 414 shows an almost-complete imperative version of the UFO class. \\ \\ | ||
| - | - Modify your code to use the imperative version of the UFO class. \\ \\ | + | ==== B. Changing the move methods ==== |
| - | ==== C. Changing the move method of the IShots union ==== | + | - From line 9 in the example code above, you can see that the move method in UFOWorld is now a void method. The examples at the bottom of page 413 show two options for writing the move method...the one on the lower left uses a void version of move in the UFO class and the one on the lower right uses an applicative version of move in the UFO class to return a new UFO object. Page 414 shows an almost-complete imperative version of the UFO class. In your version of the move method in UFO, you also need to make sure the UFO does not move off the screen as it moves randomly left and right.\\ \\ Modify any parts of your code that have errors after the UFO class is changed to be imperative so that they can work correctly with the imperative version of the UFO class. \\ \\ |
| + | - Make the move method in the IShots union imperative. This task is discussed on pages 416 through 418 of our text. The directions given there should help you complete this part. \\ \\ | ||
| + | - Next, change the move method in the AUP class, in the Shot class, and in the IShots union so that they each return void. \\ \\ | ||
| - | Make the move method in the IShots union imperative. This task is discussed on pages 416 through 418 of our text. The directions given there should help you complete this part. \\ \\ | ||
| Line 60: | Line 59: | ||
| - | + | ==== C. Complete the definition of onKeyEvent ==== | |
| - | ==== D. Complete the definition of onKeyEvent ==== | + | |
| For this part, you will work on making ''onKeyEvent'' in UFOWorld imperative. \\ \\ | For this part, you will work on making ''onKeyEvent'' in UFOWorld imperative. \\ \\ | ||
| Line 72: | Line 70: | ||
| - | ===== Part II: UFOs Fight Back! ===== | + | |
| + | |||
| + | ===== Part II: EXTRA CREDIT - UFOs Fight Back! ===== | ||
| Design UFOs that can defend themselves. The UFO should drop charges when the user hits the down arrow key, and, if one of the charges hits the AUP, the player should lose the game. A charge should descend at twice the rate of the UFO, straight down from where it is released.\\ \\ | Design UFOs that can defend themselves. The UFO should drop charges when the user hits the down arrow key, and, if one of the charges hits the AUP, the player should lose the game. A charge should descend at twice the rate of the UFO, straight down from where it is released.\\ \\ | ||
| - | ===== Part III: Extra Credit ===== | + | |
| + | ===== Part III: EXTRA CREDIT - Making the game more interesting ===== | ||
| - Add fields to the UFO class so that, instead of a single shot hitting the UFO and ending the game, at least 3 separate shots must hit the UFO before it is actually demolished. This will require an extra int field in the UFO class that is initialized to 0 and that is incremented whenever a shot hits the UFO. If you can, make the UFO shrink every time it is hit, so that on the third hit, it disappears. \\ \\ | - Add fields to the UFO class so that, instead of a single shot hitting the UFO and ending the game, at least 3 separate shots must hit the UFO before it is actually demolished. This will require an extra int field in the UFO class that is initialized to 0 and that is incremented whenever a shot hits the UFO. If you can, make the UFO shrink every time it is hit, so that on the third hit, it disappears. \\ \\ | ||