Q9: Gravitational Attraction

Table of Contents


Objectives

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

Academic Honesty

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

  • You are expected to work with your guild to develop a complete and playable scenario.
  • Do not copy code from the Internet or other sources without attribution. You may use helper classes from other sources, such as the instructor or Internet, but must attribute the code to the originator. Copying code snippets from the instructor's lesson examples or textbook without attribution is allowed.
  • You are encouraged to use the SmoothMover and Vector classes from the textbook.
  • Within your guild, you are expected to help each other develop code, artwork, music and sound according to your abilities.
  • However, for the parts of the quest marked "solo" and you must type all the code for your classes and not copy or modify it from another source. You may get help from your guild members if you get stuck. However, you must be able to explain and reproduce all code within your class.
  • You may get help from people other than your guild members if your guild members cannot help you, 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.
  • You may get help from people other than your guild members on non-code aspects of the project but must attribute their work.

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.

Guild Specifications

As a guild, create a side-view scenario that throws different projectiles combined from each guild member. The one object you cannot throw is a Cannonball because we used that example in class. Here are a few scenarios with projectiles to help you come up with ideas.

Solo Projectile Requirements

  1. Each guild member creates one or more original projectile classes that subclass SmoothMover and makes use of gravity in the scenario, except for one guild member who creates the world subclass instead.

    Use your originality to create a different projectile class. Name your projectile something else than Cannonball or any class we used in the lesson.

  2. For each one of your solo classes, add and fill in a comment block at the top of each file like the following but include your name right after the @author tag, replacing the words Your Name with your first and last name.
    /**
     * A projectile shot from a gadget.
     *
     * @author Your Name
     * @version 10/23/2017
     */
    

    Without your first and last name you may not receive any credit for your work.

  3. Each guild member creating projectiles must also create a projectile-end class that ends the projectile motion with some special visual effect. Name this class the same as your projectile class with a suffix of End. For example, a Bird projectile class would have an BirdEnd class as a companion class.

    Hint: see lesson 9.3.6: Simple Explosions for an example of this class and how to combine it with the projectile class. Notice that there is no requirement for an explosion. For example, the EndBird could just have a bird walk to the edge of the screen and disappear.

  4. Create at least two constructors for every one of your solo classes: a default constructor and an overloaded constructor. The default constructor should make it easy to see the effects of the class while the constructor with parameters should allow for setting up more varied initial conditions.

    Hint: see lesson 9.3.2: Projectiles and Gravitys for examples of these constructors.

  5. Each projectile class must subclass SmoothMover (from the Newton's Lab or the Cannon scenario) and must call at least two of the existing methods of the SmoothMover superclass.

    As a guild, you may add new methods to SmoothMover, but each projectile class must call at least two of the existing methods from the original SmoothMover subclass.

  6. In at least one of your solo projectile classes, react to gravity by accessing the GRAVITY Vector object of the world subclass.
  7. Each solo projectile class must call the getOneIntersectingObject() method with an argument of Target.class.

    Hint: see lesson 9.3.5 for an example.

Solo World Requirements

  1. One guild member creates a World subclass and its supporting classes instead of a projectile class.

    Use your originality to create a different world. Name your world something other than CannonWorld or any class we used in the lesson.

  2. For each one of your solo classes, add and fill in in a comment block at the top of each file like the following but include your name right after the @author tag, replacing the words Your Name with your first and last name.
    /**
     * A world class for the scenario.
     *
     * @author Your Name
     * @version 10/23/2017
     */
    

    Without your first and last name you may not receive any credit for your work.

  3. The world subclass must have a public static final Vector object named GRAVITY that is referred to by projectile classes of other guild members.

    Please use the specified name exactly as it makes for easier grading. Hint: see an example in lesson 9.3.2.

  4. As part of the scenario, write a support class that throws projectiles (like Cannon). Make sure the object thrower can be aimed and is fired at a correct, visually consistent angle. In the thrower class, restrict the firing rate so that objects are not fired in a continuous stream.

    Hint: see the fire() method in lesson 9.3.3. To reduce the firing rate, use the "key".equals() technique from lesson 9.3.3 or multicyle timing from lesson 6.3.5.

  5. In the projectile-thrower class, add separate methods for throwing each type of projectile. Call each method from act() using a separate keypress for each type of projectile.

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

  6. Add instructions to the world that explains how to throw each type of projectile.

    Hint: see the showText() method in lesson 4.4.2.

  7. As part of the scenario, write a support class named Target. Use an array and for-loop to add multiple Target objects to the scenario from within the world subclass.

    Please use the specified name exactly as it makes for easier grading. Hint: Use an array to specify the Target locations. See Q7: Extendng Bubbles for examples.

Guild Requirements

All guild members potentially receive the same credit for these specifications unless they have not contributed to the project in a significant way.

  1. As a guild decide which projectiles to fire and who will create the world with supporting classes.

  2. As a guild, make sure the entire project compiles and functions.
  3. All classes have a file comment block with the @author field filled out correctly.
  4. Update the README.TXT file for the scenario (Scenario Information) to:
    1. Provide all the project information like your guild name, project title and version or date like the following example.
    2. Under USER INSTRUCTIONS, list how to throw each projectile.
    3. List all guild members and their solo classes like the following example.
    PROJECT TITLE: Animal Shot
    PURPOSE OF PROJECT: Throw different projectiles.
    VERSION or DATE: MM/DD/20YY
    HOW TO START THIS PROJECT: Press run after compiling,
    AUTHORS: Your Guild Name
    USER INSTRUCTIONS:
    Use the up and down cursor keys to change the throwing angle.
    Use the left and right cursor keys to move the thrower.
    Press B to throw a Bird projectile.
    Press H to throw a Hamster Projectile.
    
    Member Classes:
    -Ed Parrish classes: ThrowingWorld, Ground, Target, Cannon
    -Emma Programmer classes: Bird projectile, EndBird
    -Justa Member: Hamster projectile, EndHamster
    -Leeroy Jenkins: No classes contributed.
    
  5. Choose one person in your guild as the "submitter" who will submit the final project from which everyone is graded.

    The submitter ensures that all the parts are combined correctly, zips the folder and submits the project into the Q8 quest slot of Canvas as explained in the section of this document: Deliverables.

Crafting Extra Credit

Adding the following are worth extra credit points:

  1. Publish your scenario on the Greenfoot Gallery and include the URL in your README.TXT file. (1 point for each guild member)
  2. Use an array of GreenfootImage objects to store multiple end-projectile images that are displayed in a sequence using the following algorithm. (2 points solo)
    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-like-class that uses a loop to initialize the entire array of images for extra credit 2 above when or before the explosion-like end-projectile object is contructed. (2 points solo)

    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.

Grading Criteria

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.

Solo Projectile Classes Evaluation

  • 10: World subclass and supporting classes added to scenario.
  • 2: Both solo actors properly documented in the file comment block.

    The @author field contains both your first and last name, and only your name, in the file comment block of your solo classes.

  • -1: Missing an overloaded constructor in one your classes. (x2)
  • -4: Projectile class does not subclass SmoothMover and call at least two methods of SmoothMover
  • -2: Projectile class does not react to the GRAVITY vector of the world.
  • -2: Projectile class does not call getOneIntersectingObject() method with an argument of Target.class.
  • -4: End-projectile class does not produce some special visual effect.

Solo World and Supporting Classes Evaluation

  • 10: A world subclass and supporting classes added to scenario.
  • 2: All solo classes properly documented in the file comment block.

    The @author field contains both your first and last name, and only your name, in the file comment block of your solo classes.

  • -2: Missing a public static final Vector object named GRAVITY in the world subclass.
  • -4: Missing projectile-thrower (cannon) class.
  • -2: Projectile-thrower object cannot be moved or aimed.
  • -1: Missing separate methods in projectile-thrower for throwing projectiles
  • -1: Missing instructions for firing projectiles
  • -2: Missing Target class.
  • -1: Missing an array specifying initial targets in the scenario.
  • -1: Missing a loop to add multiple target objects to the scenario.

Guild XP Evaluation

  • 4: Scenario looks fairly complete and functions without error or glitches during testing.
  • -2: All guild member names are listed in the README.TXT with their selected Actors, or "No classes contributed" if the guild member did not add one or more classes to the project.
  • -1: README.TXT file missing the usual LABELS or the label fields are not filled out.
  • -1: One or more classes does not contain a file comment block filed out in the specified format and with a name in the @author field.
  • -4: Project does not compile.
  • -4: No reported contribution to the project.

Maximum Score: 16, plus extra credit

Deliverables

Follow these instructions carefully and exactly to turn in your quest (assignment) to Canvas and maximize your XP:

  1. Choose one person in your guild as the "submitter" who will submit the final project from which everyone is graded.
  2. The submitter ensures that all the parts are combined correctly, zips the folder and submits the project to Canvas.

    Do NOT submit solo versions of the project as the last submission by anyone in the guild will be counted as the final version for the entire guild.

  3. As a guild or guild submitter, submit the project following these steps:
    1. Create a folder named "project" (no extra characters) and place the guild's final Scenario Mashup Project into this folder.
    2. Create a zip file containing the project and submit the zip file to the Q9: Gravitational Attraction 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: November 20 2017 @00:48:13