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: not spelling errors

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

    Default not spelling errors

    Im new to java so please give me a chance.I got some code from university but it just doesnt seem to work, I thought my problem was a spelling mistake but when i fix 1 problem i ca get many more and they dnt make any sence....

    the programs split into 4 parts,

    public class GraphicsDemo
    {
    	public static final int indent = 5;
    	public static final int topWidth = 21;
    	public static final int bottomWidth = 4; 
    	public static final int bottomHeight = 4;
     
    	public static void main(String[] args)
    	{
    		System.out.println("         Save the Redwoods!");
     
    		Triangle top = new Triangle(indent, topwidth);
    		Box base = new Box(indent + (topWidth/2)   (bottomWidth/2),
    					    bottomHeight, bottomWidth);
     
    	top.drawAt(1);
    	base.drawAt(0);
    	}
    }

    Next is

    public class Triangle extends Figure
    {
    	private int base;
     
    	public Triangle()
    	{
    		super();
    		base = 0; 
    	}
     
    	public Triangle( int theOffset, int theBase)
    	{
    		super(theOffset);
    		base = theBase;
    	}
     
    	public void reset(int newOffset, int newBase)
    	{
    		setOffset(newOffset);
    		base = newBase;
    	}
     
    	public void drawHere()
    	{
    		drawTop();
    		drawBase();
    	}
     
    		private void drawBase()
    		{
    			spaces(getOffset());
    			int count;
    			for (count = 0; count < base; count ++)
    				System.out.print('*');
    				System.out.println();
    		}
     
    		private void drawTop()
    		{
    		int startOfLine = getOffset() + (base/2);
    		spaces(startOfLine);
    		System.out.println('*');
    		int count;
    		int lineCount = (base/2) - 1;
    		int insideWidth = 1;
     
    		for (count = 0; count < lineCount; count++)
    		{
    			startOfLine--;
    			spaces(startOfLine);
    			System.out.print('*');
    			spaces(insideWidth);
    			System.out.println('*');
    			insideWidth = insideWidth + 2;
    		}
    	}	
    	private static void spaces(int number)
    	{
    		int count;
    		for (count = 0; count < number; count++)
    		System.out.print(' ');
    	}
    }

    next is:

    public class Figure
    {
     
    	private int offset;
     
    	public Figure()
    	{
    		offset = 0;
    	}
     
    	public Figure(int theOffset)
    	{
    		offset = theOffset;
    	}
     
    	public void setOffset(int newOffset)
    	{
    		offset = newOffset;
    	}
     
    	public int getOffset()
    	{
    		return offset;
    	}
     
    	public void drawAt(int lineNumber)
    	{
    		int count;
    		for (count = 0; count < lineNumber; count++)
    			System.out.println();
    }
    			public void drawHere()
     
    			{
    				int count;
    				for(count = 0; count < offset;count++)
    					System.out.print(' ');
    					System.out.println('*');
    			}
     
    }

    next is:

    public class Box extends Figure
    {
    	private int height;
    	private int width;
     
    	public Box()
    	{
    		super();
    		height = 0;
    		width = 0;
    	}
     
    		public Box( int theOffset, int theHeight, int theWidth)
    		{
    			super(theOffset);
    			height = theHeight;
    			width = theWidth;
    		}
     
    		public void reset( int newOffset, int newHeight, int newWidth )
    		{
    			setOffset(newOffset);
    			height = newHeight;
    			width = newWidth;
    		}
    			public void drawHere()
    			{
    				drawHorizontalLine();
    				drawSides();
    				drawHorizontalLine();
    			}
     
    			private void drawHorizontalLine()
    			{
    				spaces(getOffset());
    				int count;
    				for (count = 0; count < (height -2); count++)
    					System.out.println('-');
    					System.out.println();
     
    			}
    			private void drawSides()
    			{
    				int count;
    				for (count = 0; count < (height - 2); count++)
    					drawOneLineOfSides();
     
    			}
     
    			private void drawOneLineOfSides()
    			{
    				spaces(getOffset());
    				System.out.println('|');
    				spaces(width - 2);
    				System.out.println('|');
    			}
    				private static void spaces(int number)
    			{
    				int count;
    				for (count = 0; count < number; count++)
    					System.out.print(' ');
     
    			}
    }

    My error/s are in graphics demo but aremany different ones,
    just wondering can anyone spot any mistake, thanks
    Last edited by Json; April 28th, 2010 at 11:26 AM. Reason: Please use code tags!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: not spelling errors

    The compiler/jre should give a fairly precise description of what's wrong. It always helps to post that info to point us in the right direction. What I see without that is your instantiation of a Box object:
    Box base = new Box(indent + (topWidth/2)   (bottomWidth/2),
    					    bottomHeight, bottomWidth);

    The compiler needs a math operation between '(topWidth/2) (bottomWidth/2)' , I'm guessing its multiplication, so the following might work

    Box base = new Box(indent + (topWidth/2)  * (bottomWidth/2),
    					    bottomHeight, bottomWidth);

Similar Threads

  1. getting errors needed to be clear
    By erinbasim in forum Enterprise JavaBeans
    Replies: 1
    Last Post: February 4th, 2010, 03:24 AM
  2. Exception Errors
    By TIMBERings in forum Exceptions
    Replies: 1
    Last Post: December 10th, 2009, 02:13 AM
  3. Errors with LispList
    By Newoor in forum Collections and Generics
    Replies: 10
    Last Post: October 25th, 2009, 04:25 PM
  4. [SOLVED] Error of "cannot find symbol"
    By big_c in forum File I/O & Other I/O Streams
    Replies: 31
    Last Post: April 9th, 2009, 11:20 AM
  5. Ambiguity and non-static variable reference error in java
    By jenseits in forum AWT / Java Swing
    Replies: 5
    Last Post: December 8th, 2008, 07:04 PM