Write two new methods in the class Picture that implement some kind of image manipulation.The two methods can not be the same.You must use a for loop in one method and a while loop in the other! The picture that gets manipulated should be the target that receives the method (i.e., this). For example, if you implement the method "mytweak()", then you'll use it on some picture somePicture.mytweak(), and you'll expect the picture somePicture to change. (Don't bother returning a DIFFERENT picture for this method. In other words, we expect both of your methods to be void methods.)

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 email to your TA. 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.

The TA grading this homework will compile your Picture.java file in DrJava and test it using the interactions pane. They 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

Modified Picture.java.

Please include your name and Prism ID in the beginning comments

Picture.java should contain 2 new methods, one method using a for loop, the other using a while loop with comments explaining what each does.

Create a PictureCollage.java class with a public static void main(String[]args) method that, when executed, creates and shows a collage of pictures. You need to have one picture appear four times: the original time, then three other times with some image manipulation. You are welcome to add additional pictures.

The whole collage should be mirrored in some direction so that it will be, for example, symmetric horizontally or vertically. However you may NOT use any of the mirror methods in Picture.java. You have to place elements so that everything gets mirrored appropriately. We require you to use Turtle to do at least some of your drawing.

Hint: If you use two turtles to move and drop everything, a mirrored, symmetric picture will result.

You should include comments at the top of your class definition as well as throughout your public static void main(String[]args) method explaining what your code is doing or what your code should be doing.

Your method must use FileChooser.getMediaPath() to access pictures. Do not include FileChooser.setMediaPath() with your submitted code or you will get points off!

For +5 Extra Credit: Create your collage with diagonal symmetry

WHAT TO TURN IN

PictureCollage.java

(optional) Any additional pictures not included in the Media Sources folder

Using SongNodes and the Turtles, create a musical dance. Play music while the Turtles move in patterns.

Your piece must be at least 10 seconds (though it will more than likely be longer than 10 seconds).

Turtle Movements

You must have at least six Turtles. The Turtles can drop Pictures, leave trails (or not), spin slowly, etc. but your Turtles must move.

You can have your Turtles move around on a World. or you can have the Turtles move around on a Picture and use FrameSequence to play through the frames.

Music

You must use SongNode to create a linked REMOVEDst of musical nodes.

You must have at least 4 unique riffs from SongPhrase. You will be required to write at least one of these 4 riffs. You may create one by copying an existing Phrase and modifying it or you can create one completely from scratch. You also may create all 4 riffs yourself.

You must use weave, repeatNext, and repeatNextInserting to create patterns in your music. You must use weave and either of the repeating methods (repeatNext and repeatNextinserting ) at least once and for a combined total of 4 times.

You must have at least 10 SongNodes in your final list

There must be some interweaving between Turtle motion and music. In other words, you can't move the six Turtles a little then play 10 seconds of music.

Draw a picture of your resultant list structure. Show us where all the nodes are in your final composition. You can do this by drawing with a tool like Paint or Visio or even PowerPoint, or you can draw it on paper then scan it in. You can turn in JPEG, TIFF, or PPT files.

I recommend using the a modified version of SongNode.java that I have written specific to this homework. You can review the java doc. Basically I added a method playFromMeOn that will play your music automatically and does not use the note viewer. I also added a method blockingPlayFromMeOn that works like blockingPlay from Sound

You must implement your dance and music in a TurtleDance class in a main method.

Please remember to include your name and Prism ID (i.e. gtx###x or jsmith#) in your comments as well as explain what you want your code to be doing.

WHAT TO TURN IN

TurtleDance.java

SongPhrase.java (because we asked you to add more riffs)

A picture of your resultant list structure

(optional) Any additional pictures not included in the Media Sources folder

EXTRA CREDIT: You are still required to do all of the basic requirements for the assignment, but you can implement one of the following special dances for extra credit:

Dance Off (+5points)A rival gang of Turtles has challenged your gang of Turtles to a dance off. Each gang of Turtles take turns doing a dance in unison. On each turn the current gang of Turtles must repeat what the other gang did previously as well as add on new moves. There must be at least 2 turns meaning that each gang must go at least 2 times.

Turtle Waltz (+5points)Several Turtle couples have decided to do the waltz. For each couple, the partners must face each other and move together with the music. You must have at least 3 Turtle couples and an appropriate background (something like a ballroom); this means that you must have the Turtles dance on a Picture.

Turtle Concert (+5points)Intersperse music Sounds with spoken word Sounds to create a soundtrack for the concert. Choose one from the following dances:1. Superstar and Backup Dancers - A Turtle superstar is performing his/her latest song. Have at least 5 backup dancers while the Turtle superstar is singing his/her song. Remember the backup dancers’ dance is usually more elaborate than the superstar’s. 2. Boy Band - Each member of the boy band take turns stepping in front to do a part of the vocals (and perhaps his own dance) while the others dance in unison.3. Superstar, Backup Dancers, and Audience – The concept is basically just like Superstar and Backup Dancers, but instead you must have some Turtles in the audience that will also occasionally move, but how and when they move is really up to you.

Got another idea for extra credit? Get approval from any TA by midnight on Wednesday May 30, 2007. Be sure to include the name of the TA that approved your idea and explain the idea in the comments of your file.

For this homework, you must implement three additional methods in PositionedSceneElement

public void moveAllOccurrencesToTheEnd(String filename)You must move all of nodes that contain Pictures with the same specified filename to the end of the list. You can remove the nodes and then reinsert them at the end of list. You CANNOT simply discard the removed nodes and then add new nodes at the end of the list. For instance, if I were to create a linked listnode1->node2->node3->node4->node5->node6->nullIMAGE function cannot find the upload.and then execute this line of code

The resulting list would look like this:node1->node2->node6->node3->node4->node5->nullIMAGE function cannot find the upload.Also handle cases where the head of the list contains a Picture with the specified filename and also where none of the nodes contain a Picture with the specified filename. Handling a case means that you consider whether or not this case will cause an exception to occur and place code with your method to properly deal with this case when and if it does arise; you also notify the user that he tried to do something that is not allowed. For instance, the user wants to move the head of the list to the end. You can check if this case occurred with an if statement and use System.out.println() to notify the user.

if(headFilename.equals(filename)){
System.out.println("Head contains a Picture with the filename, but cannot be moved");
}

The more we think about possible user mistakes and handle them, the less likely we will get ugly runtime exceptions that have to be debugged later. Handling all possible cases is one characteristic of robust code.

Handle these cases:

The filename specified is not in the list. Notify the user.

The head of the list contains the specified filename, but cannot be removed. Notify the user.

public void addNTimesAfterNthElement(int index, PositionedSceneElement addElement, int numOfCopies)You have go through the list until you reach the position specified by index and then add the amount of copies of addElement as specified by numOfCopies. Assume the head of the list to be the 0 index. If the index is greater than the length of the list, go ahead and add to the copies of addElement to the end of the list.

Handle this case:

The index specified is greater than the length of the list. Add to the end of the list and notify the user.

public void doARandomPictureManipulation()There is a 25% chance that the Picture in the node will stay the same, but a 75% chance that it will change. You can use our good friend Math.random() to generate numbers 0-3. 0 - no change. 1 - decreaseRed. 2 - clearBlue. 3 - lighten. So for each node in the list, you must generate a random number and decide if the picture will stay the same or change.

You must also provide a class named PictureTest that has a public static void main(String[]args) method which utilizes all three of your new methods. When your TA executes the main method, it should (a) show a background with four or more pictures in it, (b) then show a new picture after using moveAllOccurrencesToTheEnd, and (c) a third picture after using then addNTimesAfterNthElement(d) a final fourth picture after using doARandomPictureManipulation(). Your TA might also test your methods with his or her own PictureTest.java so remember to handle all possible cases.

You must write HW6 using Pair Programming. Announce your pair on the Student704. Not working in a pair is a 10% score penalty (i.e., you lose one letter grade from the start.) Be sure to fill out pairProgrammersAgreement.pdf or CS1316 Pair-Programming Agreement.pdf form and turn it in to any TA or the professor. The last day to turn it in is Wednesday June 20. YOU ONLY NEED TO TURN IN ONE PER GROUP. ONLY ONE IS NECESSARY FOR HOMEWORK 6, 7 AND 8 (Not one for each assignment). YOU ONLY NEED TO TURN IN A NEW ONE (AFTER THE FIRST ONE) IF YOU SWITCH PARTNERS.

You need to:

Create a tree of images that describe your scene, henceforth referred to as the scene structure.

Create another list with the sounds to be played during the animation of this tree.

When you animate your scene (for at least 25 scenes!) and play your sounds, YOU CANNOT MAKE ANY NEW SOUNDS! You must play your sounds out of your list of sounds. In other words, the sounds must be pre-made and assembled in a structure before you start your animation.

You can use and modify any of the data structures that we've described in class. You can create new data structures if you'd like.

You will also need to create a class (call it AnimationRunner). Your TA will create an instance of this class (AnimationRunner ar = new AnimationRunner()).

The method setUp() should set up the two data structures.

The method play() should play the movie with sound.

The method replay() should replay the FrameSequence, but will not play the sound.

From here on, there are SEVERAL ways to handle the animation.
Here is one:

Render the first frame to a FrameSequence instance. (Make sure that the FrameSequence is shown.)

For each frame that you want to generate (There must be at least 25 frames):

Make a change in the scene structure. Any change you want is acceptable.

Render the scene structure.

Play the sound in the frame list element. Use blockingPlay() instead of play() on your sound to make the processing wait (synchronize) until the sound is done before moving on. (Hint: If your sound is over 1/10 of a second long, you can't get 10 frames per second! These will be short sounds! Want something to play over two frames? Play the first half in one frame, and the second half in the next frame.) Note: You do not HAVE to use blockingPlay(). You can use a mixture of play() and blockingPlay() to get better response while still maintaining synchrony.

Please put comments in your classes and before each of the methods that you create:

With your name, Prism ID (gtx000x, jsmith0)

Explaining what you're doing

Each method has a comment explaining it

Each SECTION of the code has comments explaining it.

Variable and method names should be clear and understandable.

WHAT TO TURN IN

ALL the classes that you're using for your data structures. (You don't have to turn in Picture, Sound, FrameSequence, or its related structures (unless you've changed them), but everything you are using for keeping your sound list and scene structure.)

Any additional sounds or pictures you used besides those in the MediaSources directory.

You must write HW7 using Pair Programming. Not working in a pair is a 20% score penalty (i.e., you lose two letter grades from the start.) YOU ONLY NEED TO TURN IN A NEW ONE PAIR PROGRAMMING AGREEMENT IF YOU SWITCH PARTNERS.

Write a class TurtleEtchASketch that will create a version of the classic etch-a-sketch using a Turtle and present it visually using a GUI. You will need to have a Turtle draw on a Picture canvas and use directional buttons to control the movements of the Turtle.

Components you need to include:

Directional buttons to control the Turtle.

upButton and downButton to control vertical movement.

leftButton and rightButton to control horizontal movement.

An input area (JTextArea and JTextField are good choices) to take in how many Pixels the Turtle should move each time a directional button is clicked (The default amount of Pixels should be 5).

A submitButton for the input area.

[Easier Option] 3 buttons to change the color of the line the Turtle draws or [Harder Option] use JColorChooser to change the color.

A JLabel to hold the Picture that will serve as the background for the Turtle. The background Picture can be a blank Picture, but does not have to be.

A shakeButton that clears the whole screen.

The final design and location of each of these components is ultimately up to you and your partner.

You must write HW8 using Pair Programming. Not working in a pair will result in automatic 30% score penalty.

Using the provided Simulation Package (Simulation, Agents, etc), write a new class ZombieAttackSimulation that extends Simulation and modify the PersonAgent class and implement the following:

A person and a zombie will normally wander aimlessly.

A person will turn and face the other direction if he gets within 20 steps of a zombie.

A person has a 50% chance of being killed, 30% chance of being bitten, 10% chance of not being harmed, 5% chance of killing the zombie and 5% chance of confusing the zombie and escaping completely each time the zombie attacks.

If killed by a zombie or dies from a zombie bite, the person will first turn red and then have a chance to rise again as a zombie(turn green). 50% chance in the next timestep. 75% chance in the following timestep. 100% in the timestep after that.

If bitten during a zombie attack, the person will die in 2 timesteps and then become a zombie following the same sequence from before.

If a zombie comes within 10 steps of a normal person, its speed will double and continue chasing that person until that person is caught and killed, the person confuses the zombie and escapes or the zombie itself is killed. If confused, the zombie will not move in the next timestep in order reorient itself. The zombie will return to normal speed unless it is killed.

You and your partner must implement these rules and note the number of zombies and the number of surviving people. Start with 99 people and 1 zombie. Run the simulation for 100 timesteps and record the number of zombies and the number of surviving people. Do this for a total of 3 runs and average your numbers (You will have 4 datasets: 1st run, 2nd run, 3rd run, and average).

The goal is then increase the number of people that survive and decrease the number of zombies. You and your partner must implement TWO of the below special tactical maneuvers. You and your partner should implement one of the maneuvers, try out three runs and compute the average number of people and zombies. Then you must implement a second maneuver on top of the other one. You and your partner must then produce a Word document with graphs of the number of the normal people and zombies for each of the 100 timesteps of each run.

The Word document should have:

3 graphs for the original rules

3 graphs after the first policy implementation with a description of what happened and why (include average counts of people and zombies)

3 graphs after both policies are implemented with a description of what happened and why (include average counts of people and zombies)

SPECIAL TACTICAL MANEUVERS

Teamwork

From the original 99 people, one person will be chosen randomly to be the leader and go around gathering survivors to attack the zombies as a group. People have a higher survival rate and a higher chance of killing the zombie within a group: A person has a 40%-n chance of being killed, 25% chance of being bitten, 20% chance of not being harmed, 10%+n chance of killing the zombie and 5% chance of confusing the zombie and escaping completely each time the zombie attacks, where n is the number of people in the group.

Disposing of the dead

Since there are potentially several timesteps before a person turns into a zombie, create 10 special health care workers that go around taking care of the corpses so that they cannot rise and become zombies. Have these corpses turn some color other than red and move them to a special corpse graveyard on an area of the world.

Vaccine

The doctors have developed a vaccine in limited supply. Distribute these 10 vaccines to 10 different people. These people cannot become zombies, but still can be killed by zombies.

Repopulating the world

If a female comes in contact with a male, she has a 15% of becoming pregnant. If pregnant, her speed will decrease by half, and she will give birth in 5 timesteps. There is a 50% chance that the baby will be a girl and a 50% that the baby will be a boy. If the mother is killed by a zombie before she can give birth, both her and her baby will rise as zombies.

Strategic government bombing

The government has decided to bomb areas of the world to help eliminate the zombies. The government has 2 bombs that will destroy and kill anything in a radius of 50 steps. The government can randomly drop the bombs or drop them on area with a higher concentration of zombies.

HW9 is an individual assignment, but it is dependent on a working HW8. Students are to take their completed HW8 and replace the turtle with character images.

There must be a different image for each of the following: zombies, regular people, dead zombies, and dead people.

Choose 2 of the following special types to include as well (the choice may be based on which special maneuvers you and your partner chose to implement): (1) female people and male people, (2) healthcare workers or vaccinated people, (3) pregnant women and zombie pregnant women, (4) leader and his/her followers, and (5) zombie chasing a victim and the person running away from a zombie.

There must be 2 different positions of each type of people – moving northward, moving eastward, moving westward, moving southward, etc. You must rotate among these positions changing position with each time step.

You need to turn in (4 images for the regular types + 4 images for the special types) X 2 for each different position = 16 images