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

Thread: Program is running successfully but still getting error message..

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Program is running successfully but still getting error message..

    i am trying to construct a pyramid like this (see attachment)

    my code is
    import acm.graphics.*;
    import acm.program.*;
    import java.awt.*;
     
    public class Pyramid extends GraphicsProgram {
     
    /** Width of each brick in pixels */
    	private static final int BRICK_WIDTH = 30;
     
    /** Height of each brick in pixels */
    	private static final int BRICK_HEIGHT = 12;
     
    /** Number of bricks in the base of the pyramid */
    	private static final int BRICKS_IN_BASE = 14;
     
    	public void run() {
     
    		int BaseBrick=BRICKS_IN_BASE, height=BRICK_HEIGHT,weidth=BRICK_WIDTH,x=5,y=300;
    		while(BaseBrick!=0) {
    			drawRow(BaseBrick,x,y,height,weidth);
    			BaseBrick--;
    			y-=12;
    			x+=15;
    		}
    	}
    	private void drawRow(int BaseBrick, int x, int y,int height, int weidth) {
    		for(int i=0;i<BaseBrick;i++){
    		GRect rect = new GRect(x,y,weidth,height);
    		add(rect);
    		x+=30;
    		}
    	}
    }

    after running the program i got my pyramid but also getting these error messages..(see attachments)

    someone tell me where is loophole in my code
    Attached Images Attached Images
    Last edited by helloworld922; December 23rd, 2011 at 05:23 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Program is running successfully but still getting error message..

    Not many of us have the third party packages you are using. Can you copy and paste here the error messages you are getting. Its hard to copy a String from an image for searching the text of your code.

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Program is running successfully but still getting error message..

    As far as I can tell those errors are occurring in the pyramid_final class, not the Pyramid class. I don't see a clear execution order here, what does the rest of the code look like?

Similar Threads

  1. How to display error message box
    By jasonxman in forum What's Wrong With My Code?
    Replies: 11
    Last Post: August 21st, 2011, 02:47 PM
  2. [SOLVED] Help making an error message.
    By Lost_Secret in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 1st, 2011, 04:48 PM
  3. Strange error message
    By javapenguin in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 11th, 2011, 02:03 PM
  4. How to make an error message when my program crashes?
    By noFear in forum Java Theory & Questions
    Replies: 10
    Last Post: August 11th, 2010, 08:50 AM
  5. help with a error message
    By JavaNoob82 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 23rd, 2010, 02:56 PM