CSE8A_HW4 - Homework 4: Collage & Picture Flip Due: 5:00pm,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 4: Collage & Picture Flip Due: 5:00pm, Friday, February 4th Set Up (Read this entire write-up first before starting … and START EARLY!! ! This HW can be long.) Open your home directory (double click on your cs8wxx icon; 2 nd icon from the top) and create a new directory in your home directory called hw4 (all lowercase). Copy the folder bookClasses from your Desktop into the hw4 directory. o Right click on bookClasses > Copy > Right click on hw4 > Paste Into Folder When you work in Dr. Java be sure you are editing files in the hw4/bookClasses directory. Problems 1. Collage For this part of the assignment, you will be making a collage. The first file you will create is HW4A.java . Here is a template for HW4A.java (use HW4B – later in this write-up – to help you complete this). /* * Filename: HW4A.java * Name: Your name and your partner’s name * Login: Your cs8wxx account and your partner’s cs8wxx account * Date: Month, Day, Year * Sources of Help: . .. (for example: names of people, books, websites, etc.) * * Describe what the code does here. */ public class HW4A { /* * Name: method name * * Purpose: Briefly describe the purpose of this method * * Parameters: List all parameters and their types and what they represent. * If no parameters, just state None. * * Return: Specify the return type and what it represents. * If no return value, just specify void. */ public static void main ( String[] args ) { // Insert code for HW4A here. Very similar to HW4B given later in this // write-up. } } This program will allow the user to choose a picture, and then make two copies it. This will allow you to have 3 copies of the picture. Then you will call a different filter method on each picture. You will send the 3 modified pictures to a collage method that will put them all on one picture. The three filter methods are going to be two filters of your choice plus a mirror filter. A mirror filter can be found in the book or as described below:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
public void mirrorVertical() { int width = this.getWidth(); int mirrorPoint = width / 2; Pixel leftPixel = null; Pixel rightPixel = null; for( int y = 0; y < getHeight(); y++ ) { for( int x = 0; x < mirrorPoint; x++ ) { leftPixel = getPixel( x, y ); rightPixel = getPixel( width - 1 - x, y ); rightPixel.setColor( leftPixel.getColor() ); } } } The collage method will take in all three pictures after the filters are applied and copy them onto a canvas (blank picture) that is the exact size of all three put together (more on that later). Overall this part of the assignment will put three pictures that are run through different filters next to each other on one picture. Here is what you have to do: Add three methods to Picture.java . Each method should change its
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/31/2011 for the course CSE 8a taught by Professor Kube,p during the Fall '08 term at UCSD.

Page1 / 7

CSE8A_HW4 - Homework 4: Collage & Picture Flip Due: 5:00pm,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online