hi
my complier showing me that i am having 4 errors.In t1.drawHexagon(int width); & t1.drawPentagon( int width ).Its says .class and ";" expected.
Help.

Thank you

import java.util.*;
import java.awt.*;


public class Turtle extends SimpleTurtle
{

  public Turtle (int x, int y, Picture picture) 
  {

    super(x,y,picture);
  }


  public Turtle (int x, int y, 
                 ModelDisplay modelDisplayer) 
  {

    super(x,y,modelDisplayer);
  }


  public Turtle (ModelDisplay modelDisplay) 
  {

    super(modelDisplay);
  }


  public Turtle (Picture p)
  {
    // let the parent constructor handle it
    super(p);
  }  

  /////////////////// methods ///////////////////////

public void drawSquare()
  {
    this.turnRight();
    this.forward(30);
    this.turnRight();
    this.forward(30);
    this.turnRight();
    this.forward(30);
    this.turnRight();
    this.forward(30);
  }
public void drawRectangle ( int width , int height )
  {
   this . turnRight ( ) ;
   this . forward ( width ) ;
   this . turnRight ( ) ;
   this . forward ( height ) ;
   this . turnRight ( ) ;
   this . forward ( width ) ;
   this . turnRight ( ) ;
   this . forward ( height ) ;
  }
public void drawHexagon ( int width )
  {
   this . turn ( 30 ) ;
   this . forward ( width ) ;
   this . turn ( 50 ) ;
   this . forward ( width ) ;
   this . turn ( 50 ) ;
   this . forward ( width ) ;
   this . turn ( 50 ) ;
   this . forward ( width ) ;
   this . turn ( 50 ) ;
   this . forward ( width ) ;
   this . turn( 50 ) ;
   this . forward ( width ) ;
   this . turn ( 50 ) ;
  }
public void drawPentagon ( int width )
  {
   this . turn ( 30 ) ;
   this . forward ( width ) ;
   this . turn ( 60 ) ;
   this . forward ( width ) ;
   this . turn ( 60 );
   this . forward ( width ) ;
   this . turn ( 60 ) ;
   this . forward ( width ) ;
   this . turn ( 60 ) ;
   this . forward ( width ) ;
   this . turn ( 60 ) ;
  }
  public void drawTriangle( int width )
  {
   this.turn();
   this.forward(120);
   this.turn();
   this.forward(120);
   this.turn();
      }

  public static void main(String[] args)
  {
    World earth = new World();
    Turtle t1 = new Turtle(earth);
    t1.drawSquare();
    t1.drawHexagon(int width);
    t1.drawPentagon( int width )

  }

} 

When you call a method, you don't spell out the type of the arguments - you only do that when declaring the method. I.e. if you want to call drawHexagon with width as its argument, you write drawHexagon(width) not drawHexagon(int width).

That said, unless the SimpleTurtle class has a static variable called width, the width variable isn't defined anywhere in your program. So you need to define it and set it to a sensible value before you can use it.

Also you're missing a semicolon on line 105 (that part of the error message was pretty clear, I think).

also make sure "width" variable has some assigned value or it may default to zero or some garbage value

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.