The following is a method in the Picture class: 1: public Picture sillyStuff(Pic
ID: 3801157 • Letter: T
Question
The following is a method in the Picture class:
1: public Picture sillyStuff(Picture p, Picture q)
2: {
3: int w = Math.min(Math.min(p.getWidth(), q.getWidth()), this.getWidth());
4: int h = Math.min(Math.min(p.getHeight(), q.getHeight()), this.getHeight());
// why the two calls to Math.min?
5: Picture x = new Picture(w,h);
6:
7: for (int a = 0; a < x.getWidth(); a++)
8: {
9: for (int b = 0; b <x.getHeight(); b++)
10: {
11: x.getPixel(a,b).setRed(p.getPixel(a,b).getRed());
12: x.getPixel(a,b).setGreen(q.getPixel(a,b).getGreen());
13: x.getPixel(a,b).setBlue(this.getPixel(a,b).getBlue());
14: }
15: }
16: return x;
17: }
1. In the code above, what does line 3 do?
2. Does the code above make changes to the Picture based on
A) The pixel locations
B) The pixel color values
C) Both pixel location and pixel color value
D) Ordering of parameter values
please help me! :) #java programming
Thanks in advance@
Explanation / Answer
The line 3 in the above code calculates the minimum width of he picture p and q as the width of the picture may not be equal throughout.
the above code make changes based on the Both pixel location and pixel color value
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.