高手帮忙下啊

来源:百度知道 编辑:UC知道 时间:2024/06/05 19:09:16
You should create a new method, swapRGB() for the Picture class. To do this,
you add the method to the file Picture.java.
The swapRGB() method should do the following. For each pixel in the image,
record the values for the red, green and blue color components for that pixel. Then
change them as follows.
* Assign the old red value as the new green value.
* Assign the old green value as the new blue value.
* Assign the old blue value as the new red value.

中文是:要建立一个swapRGB() method ,把照片原来是红的变成绿的,原来绿的变成蓝的,原来蓝的变成红的。

我是新手不会,所以希望高手帮帮忙啊,给个具体点得程序啊

public swapRGB(String zhaopian){
String color=zhaopian.getColor();
if(color.equals("red")){
zhaopian.setColor("green");

} else if(color.equals("green")){

zhaopian.setColor("blue");

} else if(color.equals("blue")){
zhaopian.setColor("red");
}

}
这个方法就应该
可以实现了!

public swapRGB(String zhaopian){
String color=zhaopian.getColor();
if(color.equals("red")){
zhaopian.setColor("green");

} else if(color.equals("green")){

zhaopian.setColor("blue");

} else if(color.equals("blue")){
zhaopian.setColor("red");
}

}