Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Homework for Spring 2013

Homework #1: Manipulate Pictures

Due Jan 29

Write two new methods in the class Picture that implement some kind of image manipulation.The two methods can not be the same.

What manipulation that gets implemented is entirely up to you: Increasing blue while decreasing red, flipping vertically, posterizing, etc. You must implement something NOT already implemented in the class Picture. You can use the methods that are there as examples, but do not make any calls to those existing methods to implement your new methods.

Turn in Picture.java file via T-Square. Name your methods something that makes sense for what it does and place those names in the top comments region of the Picture.java class definition. Place your methods at the bottom of the class definition, with a comment before it indicating what your method does.

Priscilla will compile your Picture.java file in DrJava and test it using the interactions pane. She will create an instance of a Picture, execute each of your defined methods on that Picture object and show() the results.

WHAT TO TURN IN


Grading Criteria



Homework 2

Due Feb 6, 2013

Modify Picture.java so that when run (i.e., running the main() method), a collage is generated and shown (via .show). Here are the specs that you have to meet:

Submit Picture.java as your turn-in. You must use good commenting style. You are bound by the honor code not to share code with anyone.

Grading Rubric



Homework 3: Picture in a Picture

Due Feb 15 2013

Write a method for class Picture that takes a picture as input and places it inside the target picture. Call the method composeInAPicture. These are the inputs to the method:

Scale the input picture so that it only takes up a maximum of 25% of the area of the original picture.

Here's an example of how you might use this:

> Picture canvas = new Picture(FileChooser.getMediaPath("barbara.jpg"))
> Picture swan = new Picture(FileChooser.getMediaPath("swan.jpg"))
> swan
Picture, filename /Users/guzdial/Desktop/MediaComp/mediasources/swan.jpg height 360 width 480
> canvas
Picture, filename /Users/guzdial/Desktop/MediaComp/mediasources/barbara.jpg height 294 width 222
> canvas.composeInAPicture(swan,"LR")


Here's what's going on inside the method:

// What is 25% of the height and width of the canvas?
> 0.25 294
73.5
>0.25 222
55.5
// What's the scaling for the 360 x 480 swan?
> 73.5 / 360
0.20416666666666666
> 55.5 / 480
0.115625
// Make a small enough swan, taking the minimum of those two numbers.
> Picture lilswan = swan.scale(0.11)
> lilswan
Picture, filename None height 40 width 53


We now want to compose the swan for "LR" so that it's at 222 (width of canvas) - 53 (width of lilswan), and 294 (height of canvas) - 40 (height of lilswan), which is essentially this:

> lilswan.compose(canvas,222-53,294-40)


With a result of:
composedpicture.jpg

Submit Picture.java as your turn-in. You must use good commenting style. You are bound by the honor code not to share code with anyone.

Grading Rubric



Homework 4: Use Weaving and Repeating to Create Music (Woven Music)

Due Feb 20

Using the methods developed in class to play with linked list of music, create a song.

You only have to use SongNode and have a single part with a single instrument. It does not need to autoplay!

You will create a class (with some cunning name like MyWovenSong) with a main that will assemble your song, then open it with showFromMeOn (or show–whatever you need to do open up the notation View on your masterpiece). Please put comments in your class:
  1. With your name, GT-email address
  2. Explaining what you're doing

Turn in to T-Square:


Grading Rubric


Homework 5: Use Weaving and Repeating to Create A Pattern (Woven Images)

Due Feb 27

Using the methods developed in class to create a pattern of repeated images with PositionedSceneElement. You are going to write code like this:
External Image

To produce images like this:
External Image


You will be modifying PositionedSceneElement. Please put comments in your methods:
  1. With your name, GT-email address
  2. Explaining what you're doing

Turn in to T-Square:

Grading Rubric


HW6: Doubly Linked Lists

Due March 6
For this homework, you are going to create a subclass of LayeredSceneElement called LayeredSceneElementDoubly which adds in previous links. LayeredSceneElementDoubly nodes should do everything that LayeredSceneElement nodes can do, but internally, they have a link to the previous node. See page 154 in the book for some discussion of doubly linked lists, and see the video http://www.cc.gatech.edu/~mark.guzdial/videos/sceneElementWithPrevious/ for an implementation of doubly linked lists with PositionedSceneElement.

Criteria that you must meet:

You will implement your LayeredSceneElementDoubly class with a PARTNER using PAIRED PROGRAMMING. THIS IS A REQUIREMENT. Any solo efforts will lose 15 points immediately. You can learn more about Pair Programming. In your comments, you must state who your partner is and state, "No more than 25% of the program code was written apart from one another. Each of us spent half of the time together at the keyboard, with the other one watching over and navigating."

Test code

Here's how we might test your code, and what the points will be worth. (I'm writing this freestyle, so beware of typos below. If there is casting to be done to make it work, we can fit that in.)

Picture ptree = new Picture(FileChooser.getMediaPath("tree-blue.jpg"));
Picture pdog = new Picture(FileChooser.getMediaPath("tree-dog.jpg"));
LayeredSceneElementDoubly node1 = new LayeredSceneElementDoubly(ptree,10,10); // 10 points for getting the class to work
node1.insertAfter(new LayeredSceneElementDoubly(pdog,20,10));
node1.getNext().insertBefore(new LayeredSceneElementDoubly(pdog.scale(0.5),30,10);
System.out.println(node1.getNext().getNext() == node1.last()); // Should be true. 5 points
System.out.println(node1.getNext() == node1.getNext().getNext().getPrevious()); // Should be true. 10 points for getting the links correct here
System.out.println(node1 == node1.getNext().first()); // Should be true. 5 points
Picture bg = new Picture(500,500);
node1.drawFromMeOn(bg); // Should work. 10 points
Picture bg2 = new Picture(500,500);
node1.last().drawFromMeBackwards(bg2); // Should work. 20 points.
node1.remove(node1.getNext()); // 20 points
// 20 points for not implementing anything in the subclass that could just be inherited from superclass.


Here's what the code might look like with all the correct casts


public class TestCode2 {

public static void main (String [] args){

Picture ptree = new Picture(FileChooser.getMediaPath("tree-blue.jpg"));

Picture pdog = new Picture(FileChooser.getMediaPath("tree-dog.jpg"));

LayeredSceneElementDoubly node1 = new LayeredSceneElementDoubly(ptree,10,10); // 10 points for getting the class to work

node1.insertAfter(new LayeredSceneElementDoubly(pdog,20,10));

((LayeredSceneElementDoubly) node1.getNext()).insertBefore(new LayeredSceneElementDoubly(pdog.scale(0.5),30,10));

System.out.println(node1.getNext().getNext() == node1.last()); // Should be true. 5 points

System.out.println(node1.getNext() == ((LayeredSceneElementDoubly)node1.getNext().getNext()).getPrevious()); // Should be true. 10 points for getting the links correct here

System.out.println(node1 == ((LayeredSceneElementDoubly)node1.getNext()).first()); // Should be true. 5 points

Picture bg = new Picture(500,500);

node1.drawFromMeOn(bg); // Should work. 10 points

Picture bg2 = new Picture(500,500);

((LayeredSceneElementDoubly)node1.last()).drawFromMeBackward(bg2); // Should work. 20 points.

node1.remove(node1.getNext()); // 20 points

// 20 points for not implementing anything in the subclass that could just be inherited from superclass.
}
}


Homework 7: Make a Movie using Scene Graphs

Due March 15

Use the same classes as in WolfAttackMovie, but tell a different story with different pictures.

Criteria


Turn in your animation class and all your JPEG files.

You MUST do this as a Pair Programming activity, or you lose 15 points. Include an honor statement with your partner's name (both of you turn in the same code, and collaborate with no one else but your partner) and a claim that you each typed in approximately half of the overall code.

Homework 8: Sprite Animation

Due April 3

Two parts to this assignment:

(65 points) A. Create a class SpriteAnimation that will hold a list of pictures (using any data structure you choose) and a pointer to the current picture.  A SpriteAnimation understands an add() method that takes another picture and adds it to the list of pictures.  Each time a SpriteAnimation is told to getNext(), it returns the picture currently pointed to by the current-picture-pointer, then moves the current-picture-pointer to the next picture.  When the current-picture-pointer gets to the end of the list, it moves to the start of the list. (20 points for creating the class with the right instance variables, 10 points for a working constructor, 10 points for a working add() method, 10 points for a working getNext() method that returns a picture, 15 points for getting the circularity right.

I'm happy for you to define getNext() in other ways, but here's what needs to happen:

(35 points) B. Create a main() method in SpriteAnimation that creates a sprite animation and fills it with at least four pictures.  Generate an animation (using FrameSequence) with at least 30 frames using any additional pictures you want and also using your SpriteAnimation instance. (10 points for creating a SpriteAnimation, 5 points for filling it correctly with pictures, 10 points for generating an animation using FrameSequence, and 10 points for making it at least 30 frames long.)

Bonus 10 points: Make your animation move around the frame.

You must do this assignment in a pair.



Homework 9: Add the Hunters

Due April 12

Modify the Foxes and Rabbits Greenfoot scenario (like how we did in the adding Corn video) to add a Hunter class.

There are three parts to this assignment:


  1. Implement the Hunter as described. Create three hunters and drop them into the Foxes and Rabbits simulation. Call this simulation "foxes-and-rabbits-and-hunters."
  2. If you already have a pretty good equilibrium with Part #1, you can skip Part #2 and move on to Part #3. Now, save a copy of your simulation. Create another version of this simulation, where you try to maintain more equilibrium. You are welcome to change any one variable in your simulation, such as decreasing the number of hunters, decreasing how far away they can see, increasing the fox likelihood percentage in Field (thus creating more foxes), increasing the breeding variables for foxes. Call this simulation "foxes-and-rabbits-and-hunters-balanced." In your comments in the class Hunter, explain what you changed and why you think it worked.
  3. Now make another copy of "foxes-and-rabbits-and-hunters." Give hunters the ability to shoot up to one fox or rabbit per turn (only one shot object per call to act()). Try to find a setting of number of hunters and variables on foxes and rabbits where this new ecology is balanced. Call this simulation "foxes-and-rabbits-and-omnivore-hunters". In your comments in the class Hunter, explain what you changed and why you think it worked.

Turn in a zip file containing all three scenarios.

Grading Rubric


You must do this as a pair (or triplet) or receive -15.

Homework 10: Disease Propagation and Public Policy

Due April 19

Do Exercise 16.10 on Page 430 in the book. Make sure that you do 3 runs of the initial condition, so that you can compare the health policies to the baseline.

Grading Rubric

Hand in your code, and also your report (as Word or PDF)

You must do this as a pair (or triplet, if necessary), or receive -15.

OPTIONAL Homework 11: Villagers with Images

Due April 24

This is an optional homework, for extra credit only. Any points on this go toward your homework grade.

Do Exercise 16.6 on page 429. Turn in a zip file with the classes you add to the Simulation classes (and any Simulation classes you changed), as well as the JPEG images that you use to represent the villagers and the NBD. (Each pair turns in the same zip file.)

Grading Rubric


There is an additional 20 points available! Implement the villagers and NBD as a Sprite Simulation (10 points each), using the class you created for HW8!

Link to this Page