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 2 of 2

Thread: cannot be resolved to a type

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

    Default cannot be resolved to a type

    So I'm really new to java programming and of course I've gotten down to the wire on an assignment and I'm stuck. I keep getting the error "plotBar cannot be resolved to a type" and I'm really clueless as to what to do I've tried many things and I'm stumped, my only other programming experience is in C programming.

    Here's what I'm supposed to do:

    A public method plotBar which returns nothing and takes in order these arguments: an
    int for the x-coordinate of the bar's lower-left corner, an int for the y-coordinate of the bar's
    lower-left corner, a double for the bar's width, and a String for the bar's text label. Suppose
    this method is called with:

    plotBar(10, 20, 57.5, "Vegan Republicans");

    Then this method prints the text:
    newpath
    10 20 moveto
    57.5 0 rlineto
    0 BAR_HEIGHT rlineto
    -57.5 0 rlineto
    closepath
    fill
    67.5 20 moveto
    (Vegan Republicans) show

    This code traces the perimeter of the bar and fills it. The last two lines print the label text
    starting at the lower-right corner of the bar.

    Here's my code:

    package hw1;
     
    public class BarPlot {
     
    	public static final int BAR_HEIGHT = 20;
     
    	public void plotBar(int givenX, int givenY, double givenWidth, String name){
    		private int x, y;
    		double width;
     
    		x = givenX;
    		y = givenY;
    		width = givenWidth;
     
    	}
     
    }

    Other than the error I was trying to figure if I'm entering the string in the method parameters correctly.
    Thanks for any help you can give(and yeah its due tomorrow )


  2. #2
    Member
    Join Date
    Feb 2010
    Location
    Auburn, AL
    Posts
    31
    Thanks
    0
    Thanked 8 Times in 8 Posts

    Default Re: cannot be resolved to a type

    This may be silly, but you are instantiating an object of type BarPlot and then invoking the plotBar method on that instance, correct? That is, you're using it as follows:

    BarPlot bp;
    bp.plotBar(...);

    That should work, I'd imagine, unless there's some other technical issue happening. If you don't want to have to instantiate an instance of the class, make plotBar static and then you can call it like

    BarPlot.plotBar(...);

    Hope this helps... probably not in time, but maybe useful for next time? Let me know...
    Let me know what you think of my website:
    http://www.auburn.edu/~carpept
    Comments or suggestions are appreciated!

Similar Threads

  1. unablissues wit type Date
    By cysquatch1 in forum Object Oriented Programming
    Replies: 2
    Last Post: December 21st, 2009, 12:20 PM
  2. Performance of Type Casting and Conversions
    By fritzoid in forum Java Theory & Questions
    Replies: 1
    Last Post: October 1st, 2009, 07:56 PM
  3. Error msg : 'pageContext' cannot be resolved in tag file....
    By saikrishna436 in forum JavaServer Pages: JSP & JSTL
    Replies: 5
    Last Post: September 8th, 2009, 07:58 AM
  4. Java error "java.lang.StackOverflowError"
    By sanatkumar in forum Exceptions
    Replies: 2
    Last Post: July 7th, 2009, 02:40 PM
  5. Type casting error in Java
    By Eric in forum Java Theory & Questions
    Replies: 3
    Last Post: December 13th, 2008, 04:11 PM