CS 123 - Programming Assignment 3

In this assignment you will write a method that modifies a picture object. This assignment is due Monday, October 5.

Add a method called permuteColors() to the Picture class that permutes the three primary colors of every pixel in the picture. That is, this method should modify every pixel in the picture object by moving the red color value of the pixel into the green color value, moving the (original) green color value into the blue color value, and by moving the (original) blue color value into the red color value.

Write a program called TestPermuteColors.java that tests your method. Your test program's main() method should open the picture file C:\cs123\mediasources\pictures\shops.jpg, send the permuteColors() message to the picture object, save the result as the file testresult1.jpg, then send the permuteColors() message again to the picture object and save the resulting picture in the file testresult2.jpg and then send the permuteColors() message one more time to the picture object and save the resulting picture in the file testresult3.jpg.

NOTE: Using the write() method from the Picture class to save a picture object is briefly mention at the bottom of page 88 of the textbook (and the top of page 89).

Turn in a zip file called CS123Hw4Surname.zip containing your Picture.java file, your TestPermuteColors.java file, and your three resulting image files testresult1.jpg, testresult2.jpg, and testresult3.jpg. This assignment is due Monday, October 5.


Return to the main homework page.
Return to the CS 123 home page.


compliments and criticisms