# Q9: Gravitational Attraction

## Objectives

• Move objects using `SmoothMover`.
• Simulate gravity in a scenario.
• Set direction and speed using vectors.
• Continue exploring pair programming.

Read the Scholastic Honesty Policy and Assignment Integrity policies of the syllabus. Here are some clarifications for this particular assignment:

• You are encouraged to work with one other student of this class following the rules of Pair Programming for Homework Assignments. If you choose to pair program, there is a bonus applied.
• You may copy small portions of the code from the textbook or the instructor's web pages.
• You may get help from people other than your pair-programming partner if you get stuck, but only if they do not show or tell you the code to type. Instead they should show you other examples that you can adapt to your code.
• Do NOT copy or modify code from, nor provide code to, any other student or unauthorized source.
• Do NOT give a copy of your code to your designated pair-programming partner if you did not develop the code together.

If you get stuck, take a break and come back to it later, talk to the professor, or ask a classmate for help. Remember, do not allow the classmate to type code for you or show you code to copy. Instead the classmate should show you techniques using other examples that you can adapt.

## Project Crafting Specifications

Complete the following specifications for your programming project:

1. Create a side-view scenario that throws an object, but not a `Cannonball` as shown in class. Make sure there is NO `Cannonball` class in the scenario or you will get marked down. Some suggestions to get you started are:
2. Make sure the object thrower can be aimed and is fired at a correct, visually consistent angle.

Hint: see the `fire()` method in lesson 9.3.3.

3. When throwing the object, restrict the firing rate so that objects are not fired in a continuous stream.

Hint: Use the `"key".equals()` technique from lesson 9.3.3 or multicyle timing from lesson 6.2.5 to reduce the firing rate.

4. As part of the scenario, include a class named `Ground` for actors to stand upon. Use a loop to add multiple `Ground` tiles to the scenario in the World subclass.

Please use the specified name exactly as it makes for easier grading.

5. The scenario must have at least one actor that subclasses `SmoothMover` (from the Newton's Lab or the Cannon scenario) and must call at least two of the existing methods of the `SmoothMover` superclass.

You may add new methods to `SmoothMover` but must call at least two of the existing methods.

6. The scenario must have at least one vector named `GRAVITY` in at least one class.

Please use the specified name exactly as it makes for easier grading.

7. The scenario must have an `Actor` subclass named `Target` and at least one class must call the `getOneIntersectingObject()` method with an argument of `Target.class`. (see lesson 9.3.5)

Please use the specified name exactly as it makes for easier grading.

8. Update the README.TXT file (Scenario Information) for your project to fill in all the information like your name (with pair-programming partner name), project title and version or date, as well as providing the current status.

Be sure to include the usual titles like PROJECT TITLE, VERSION or DATE and AUTHORS so I can easily find the information.

9. Submit a zip file (with all source code) of your original project to Canvas as explained in the section of this document: How to Submit.

## Crafting Extra Credit

Adding the following are worth extra credit points:

1. Complete the programming project using pair programming. (2 points)
2. Use an array of `GreenfootImage` objects to store multiple explosion images that are displayed in a sequence using the following algorithm. (2 points)
1. Declare an array of images and assign each element a new `GreenfootImage` object.
2. Declare a `private` counting variable to index the array.
3. In `act()`, or a method called by `act()`, increment the counting variable.
4. In `act()`, or a method called by `act()`, call `setImage()` with an argument of the array indexed by the counting variable
5. Add an `if`-statement to decide when to delete the explosion.
3. Write a method named `initializeImages()` in the `Explosion` class that uses a loop to initialize the entire array of images for extra credit 1 when or before the `Explosion` object is contructed. (2 points)

Hint: see how arrays were used in the Piano scenario for white notes (lesson 7.3.4).

Make certain that your `README.TXT` file describes any extra credit attempted.

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the syllabus page.

#### Project Compilation

• 4: Source code compiles with no errors or warnings
• 2: Source code compiles with warnings
• 0: Does not compile, not turned in, or wrong folder name

#### Project Functionality

• 10: Demonstrates mastery of the assignment
• Has extra features or demonstrates techniques beyond the assignment
• Applies concepts from the lesson(s) appropriately
• Meets all specifications (see above) with particularly elegant solutions
• No errors encountered during operation
• 8: Has all the functionality expected of the assignment
• Demonstrates many techniques from the lesson
• Meets all specifications (see above)
• Implementation seems more complicated than necessary.
• May have one minor error
• 6: Has most of the functionality expected of the assignment
• Demonstrates some techniques from the lesson
• Meets all but one of the specifications (see above)
• Implementation seems excessively complicated.
• May have 2-3 minor errors or has not pair programmed
• 4: Has some of the functionality expected of the assignment
• Demonstrates some techniques from the lesson
• Meets at least 1/2 of the specifications (see above)
• Implementation seems excessively complicated.
• May have more than 3 minor errors
• 2: Serious functional problems but shows some effort and understanding
• Meets less than 1/2 of the of the specifications (see above)
• Has a major error or many minor errors
• Implementation seems very convoluted
• Demonstrates few techniques from the lesson
• 0: Does not execute, no specifications met, or wrong folder name
• -2: penalty for not use pair programming

• 2: README.TXT file submitted with specified information included
• 1: README.TXT submitted but some information was not included
• 0: No README.TXT submitted or wrong folder name

Maximum Score: 16, plus extra credit

## How to Submit

Submit means that you are presenting your work for consideration and grading. Follow these instructions carefully and exactly to turn in your quest (assignment) and maximize your XP:

1. Create a folder named "project" (no extra characters) and place your project crafting files in this folder, including your "project.greenfoot file".
2. Zip the folder and submit the zip file to the Q8 quest slot of Canvas.

Please do not put any spaces or special characters like #, : or \$ in zip file or folder names. Your assignment must work as submitted. Remember to test and double check your files before submitting them. If you make a mistake, you can resubmit up to the deadline but must resubmit all your assignment files.

Home | Canvas | Schedule | Syllabus | Room Policies
Help | FAQ's | HowTo's | Links
Last Updated: April 04 2017 @00:46:29