Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-02-2012, 07:05 PM   PM User | #1
Wevcss
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Wevcss is an unknown quantity at this point
Calling this method

Super noobie question but I don't have a clue..
Code:
  public void changeWhole(double amount)
  {
    Pixel[] pixelArray = this.getPixels();
    Pixel pixel = null;
    int value = 0;
    int i = 0;
    while( i < pixelArray.length)
    {
      pixel = pixelArray[i];
      value = pixel.getBlue();
      pixel.setBlue((int) (value * amount));
      i++;
    }
  }
  
  
  public static void main(String[] args) 
  {
     String fileName = FileChooser.pickAFile();
     Picture pictObj = new Picture(fileName);
     pictObj.explore();
  }
I dont know how to call the changeWhole method in the main method without getting any errors.
Wevcss is offline   Reply With Quote
Old 11-02-2012, 08:59 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Is the class this method resides in "Picture"? If so, you can just use in the main: pictObj.changeWhole(50.0); for example. That should be the correct way to call it.
That doesn't mean you won't get other errors, but the method itself appears to be written to prevent errors as much as possible. The only one that should be possible to throw an error is pixelArray.length, which will only occur if this.getPixels() returns void or null.
That assumes you are not referring to a compilation error though.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:29 AM.


Advertisement
Log in to turn off these ads.