Question: void testFlipHor ( ) { ? ? 1 { : ? ? | I - ) | d o t s d o t s

void testFlipHor()
{
??1
{:??|I-)|dotsdots||
??|?bar(l)|:
??I-|??-???(-)|??-|??-'|
//
// The method name should be mirrorHorizontal and will Flip the image
// Horizontally or from left to right.
// Create two Picture image objects using the same image file
Picture p= new Picture(PictureExplorer.imageFolderName + "bees.PNG");
// Apply the student code and solution code
Logic.mirrorHorizontal (p);
Pixel[][] studentSol = p.getPixels2D();
Pixel[][] pixels = p.getPixels2D();
// The left-most and right-most pixel colors should be swapped if flipped was
// successful
// check value values of a couple of pixels - check red
assertTrue(pixels[0][0].getRed()== studentSol[0][studentSol[0].length -1].getRed());
// check green
assertTrue(pixels [0][0].getGreen()== studentSol [0][studentSol [0].length -1].getGreen());
// check blue
assertTrue(pixels[0][0].getBlue()== studentSol[0][studentSol[0].length -1].getBlue());
}
(Hello, I am trying to flip in image horizontaly, the code above is what I need to test and the hint I was given was: You may be tempted to swap Pixel objects, but for this assignment, just swap colors between Pixel objects. This is the start of my code:
public static void mirrorHorizontal(DigitalPicture picture){
Pixel[][] pixel2D = picture.getPixels2D();
for (int r =0; r pixel2D.length; r++)
{
for (int c =0; c pixel2D[r].length/2; c++)
 void testFlipHor() { ??1 {:??|I-)|dotsdots|| ??|?bar(l)|: ??I-|??-???(-)|??-|??-'| // // The method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!