Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: New to programming

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default New to programming

    Im trying to write a method here:
    public void edgeDection(double amount) 
    {
      Pixel topPixel = null;
      Pixel bottomPixel = null;
      double topAverage = 0.0;
      double bottomAverage = 0.0;
      int endY = this.getHeight() - 1;
      for 9int y = 0; y <endY; y++) {
        for (int x = 0; x < this.getWidth(); x++) {
          topPixel = this.getWidth(x,y);
          bottomPixel = this.getPixel(x, y+1)
            topAverage = topPixel.getAverage();
          bottomAverage = bottomPixel.getAverage();
          if (Math.abs(topAverage = bottomAverage) < amount) {
            topPixel.setColor(Color.White);
          } else {
            topPixel.setColor(Color.GREEN);
          }
        }
      }
      }
    This is what I am writing in the interactions panel to invoke the method:

    > String fileName = FileChooser.getMediaPath("butterfly1.jpg");
    > Picture p = new Picture(fileName);
    > p.explore();
    > p.edgedetection(10);

    these are my errors:

    Error: /home/milanomj/Desktop/edgedection.java:1: class, interface, or enum expected
    Static Error: No method in Picture with name 'edgedetection' accepts arguments (int)

    I have no idea why this isnt working, or rather any of my methods are working.
    Last edited by helloworld922; March 30th, 2010 at 07:08 PM. Reason: please use [code] tags!


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: New to programming

    well i assume you have made edgeDetection part of the Picture class, and well that error is suggesting that you should be passing a DOUBLE not an INT
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: New to programming

    Ah no I wasnt in the class for making methods attached to a class.... That would explain why non of my methods are working

    how exactly do you do that or do you know of a tutorial of how to do this

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: New to programming

    Well if Picture is your own class then you can just add the methods into it, it's hard to see exactly what is going on.

    Chris
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: New to programming

    Okay well I dont know if this will help but I am using Dr. Java....


    Also is there anyway you could just give any example of how to declare the class for the method?

  6. #6
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: New to programming

    public class MyClass{
            private int myClassVariables;
     
            public MyClass(){
            } // Constructor
     
            public int myIntReturningFunction(){
                   return 2;
           }
    }

    You get the idea
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

Similar Threads

  1. Is Java Programming Best?
    By messenger in forum Java IDEs
    Replies: 3
    Last Post: May 4th, 2010, 09:11 PM
  2. Please help me with this Java programming
    By simply_stunning79 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 12th, 2010, 07:04 AM
  3. Please help me with this Java programming
    By simply_stunning79 in forum Algorithms & Recursion
    Replies: 1
    Last Post: February 22nd, 2010, 06:48 PM
  4. Towards java programming...
    By emigrant in forum Member Introductions
    Replies: 1
    Last Post: February 15th, 2010, 02:17 AM
  5. Please help me with this Java programming
    By simply_stunning79 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 14th, 2010, 05:42 AM