For this question you will be using Pixel objects and one Picture object:
Here's what the Pixel class looks like:
public class Pixel {...
For this question you will be using Pixel objects and one Picture object:
Here's what the Pixel class looks like:
public class Pixel {
private int rValue;
private int gValue;
private int bValue;
private int xCoord;
private int yCoord;
public Pixel(int x, int y) {
xCoord = x;
yCoord = y;
rValue = 0;
gValue = 0;
bValue = 0;
}
public int getRed() {
return rValue;
}
public void setRed(int rValue) {
this.rValue = rValue;
}
public int getGreen() {
return gValue;
}
public void setGreen(int gValue) {
this.gValue = gValue;
}
public int getBlue() {
return bValue;
}
public void setBlue(int bValue) {
this.bValue = bValue;
}
And a Picture Class that can hold many Pixel objects. These can be accessed through the getPixels()
method in the Picture class.
For this method, the goal of this method is to return an int value that is the sum of the red value of all the Pixels in the Picture.
In the for-each loop, change the value of the total
variable so that the red value from every pixel is added to it.
Your feedback will appear here when you check your answer.