Results 1 to 6 of 6
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Basic Java help needed

  1. #1
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default Basic Java help needed

    Hello, I am a graphics and animation student, and part of my course is to learn to code with Java. I am at a complete loss here as to what I am actually doing. This is my code copied from an example in a textbook, but it does not compile, obviously I'm missing something here.


    Java Code:
    /**
     * Method to lighten the colors in the picture
     */
    public class RemoveBlue {
      
      public void clearBlueNested()
      {
        Pixel pixel = null;
        
        // loop though the columns (x direction)
        for (int x = 0; x < getWidth(); x++)
        {
          // loop through the rows (y direction)
          for (int y = 0; y < getHeight(); y++)
          {
            // get pixel at the x and y location
            pixel = getPixel(x, y);
            
            //clear the blue
            pixel.setBlue(0);
          }
        }
      }
      
    }
    When I attempt to compile, I get the following messages:

    3 errors found:
    File: C:\Documents and Settings\Scott\My Documents\UNISTUFF\cm1015\Semester2\JavaForMonday2 8th\RemoveBlue.java [line: 12]
    Error: The method getWidth() is undefined for the type RemoveBlue
    File: C:\Documents and Settings\Scott\My Documents\UNISTUFF\cm1015\Semester2\JavaForMonday2 8th\RemoveBlue.java [line: 15]
    Error: The method getHeight() is undefined for the type RemoveBlue
    File: C:\Documents and Settings\Scott\My Documents\UNISTUFF\cm1015\Semester2\JavaForMonday2 8th\RemoveBlue.java [line: 18]
    Error: The method getPixel(int, int) is undefined for the type RemoveBlue
    It says undefined methods. Do I need to write these methods? I've constructed simple getter and setter methods in the past but the textbook and lectures don't make it clear whether more code is needed for these examples to function. I'm obviously missing something very simple here :confused:

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You either have to create these methods if you're going to use them or perhaps the RemoveBlue class is supposed to extend another class that already has these methods -- it's hard to say without more information.

  3. #3
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    Well, it turns out I was supposed to be inserting these methods into a ready-made Picture.java class that came with the textbook. I think I've got it working now, maybe. :mad:

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  5. #5
    Naomi.Kennedy is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Default Re: Basic Java help needed

    hey i'm actually working on this now and having the same problem, how did you get it to work?
    thanks in advance :)

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Basic Java help needed

    Quote Originally Posted by Naomi.Kennedy View Post
    hey i'm actually working on this now and having the same problem, how did you get it to work?
    thanks in advance :)
    Please don't re-activate an old thread. If you have a question, then please start your own thread, show what you've tried, explain how it doesn't work, and ask any specific questions in that new thread. This old thread is now locked.
    DarrylBurke likes this.

Similar Threads

  1. Basic Java help, AIM?
    By jkswebsite in forum New To Java
    Replies: 4
    Last Post: 07-11-2012, 06:17 PM
  2. Basic java help =)
    By Xycose in forum New To Java
    Replies: 1
    Last Post: 06-30-2010, 02:20 AM
  3. basic java
    By vijay24805 in forum New To Java
    Replies: 25
    Last Post: 04-14-2009, 02:46 AM
  4. basic help needed
    By CurtisJC in forum New To Java
    Replies: 2
    Last Post: 03-02-2009, 07:21 PM
  5. basic java help
    By adred in forum New To Java
    Replies: 0
    Last Post: 03-08-2008, 12:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •