I understand overloading but what does someone mean by "Overload the increaseRed method with an increaseRed method that accepts a number that specifies an increase factor"?

The increasedRed() is as follows:

 public void increaseRed()
{
  Pixel[] pixelArray = this.getPixels();
  Pixel pixel = null;
  int value = 0;
  int index = 0;

  // loop through all the pixels
  while (index < pixelArray.length)
  {
    // get the current pixel
    pixel = pixelArray[index];

    // get the value
    value = pixel.getRed();

    // change the value to 1.3 times what it was
    value = (int) (value * 1.3);

    // set the red value to 1.3 times what it was
    pixel.setRed(value);

    // increment the index
    index++;
  }
}

Recommended Answers

All 4 Replies

Does this make sense?

public void IncreaseRed ( int percent )
{
Pixel [] pixelArray = this.getPixels();
int red = 0 ;
double factor = 1 . 0 - ( percent / 1 0 ) ;
// loop through a l l the p i x e l s
for ( Pixel currPixel: pixelArray )
{
red = currPixel . getRed() ;
currPixel.setRed ( ( int ) ( red * factor ) ) ;
}
}

Yes, that makes complete sense to me (except line 5 where the math looks suspect).

I understand overloading but what does someone mean by "Overload the increaseRed method with an increaseRed method that accepts a number that specifies an increase factor"?

this line alone tells me you don't understand overloading.

Wow no answer

this one tells me you don't recognize an answer when given one. what kind of answer are you expecting?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.