wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes identifier expected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "identifier expected" Watch "identifier expected" New topic
Author

identifier expected

Rob Michaelson
Ranch Hand

Joined: Jul 15, 2003
Posts: 36
Hello,
I tried to follow a link to answer this question but it was gone. I am getting an identifier expected error ( I am using BlueJ) and I am pretty sure I just need a "{" or something.?
Here's the stuff:
public class MyHouse extends AView
{

// instance variables
private AUpTriangle theRoof;
private ARectangle theHouse;
private ARectangle theDoor;
/**
* Constructor for objects of class MyHouse.
* This creates a MyHouse object at the specified
* location
* @param x the x-coordinate for the object
* @param y the y-coordinate for the object
*/
public MyHouse(int x, int y)
{
// Specify the constructor for the superclass
super(x, y, 120, 100);
// Create the roof object
theRoof = new AUpTriangle(0, 0, 120, 40);
// Set the characteristics of the roof
theRoof.setToFill();
theRoof.setColor(new Color(0x99, 0x33, 0x00));
// Place the roof in the MyHouse object
theRoof.place(this);
// Create the house object
theHouse = new ARectangle(10, 40, 100, 60);
// Set the characteristics of the house
theHouse.setToFill();
theHouse.setColor(Color.blue);
// Place the house in the MyHouse object
theHouse.place(this);
// Create the door object
theDoor = new ARectangle(48, 50, 24, 50);
// Set the characteristics of the door
theDoor.setToFill();
theDoor.setColor(new Color(0x99, 0x66, 0x33));
// Place the door in the MyHouse object
theDoor.place(this);
}
/**
* This is an overload for the constructor. It takes
* three parameters
*/
ERROR>>>>>>>>>> public MyHouse(int x, int y, java.awt.Color)
{
}

Thanks
Rob

}
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Originally posted by Rob Michaelson:
I tried to follow a link to answer this question but it was gone.

The link was gone or did the link just not go anywhere?


Notice that you have no variable after "java.awt.Color" in your constructor. Try
public MyHouse(int x, int y, java.awt.Color c)


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Rob Michaelson
Ranch Hand

Joined: Jul 15, 2003
Posts: 36
yes - I got it
Thank you!
public MyHouse(int x, int y, java.awt.Color cyan)
I am asked to add an additional house to MyScene using both constructors - can you give me a clue?
MyScene code:
public class MyScene extends AWindow
{
// instance variables
MySun sun;
/**
* Constructor for objects of class MyScene
*/
public MyScene()
{
// Specify the constructor for the superclass
super(10, 10, 400, 300);
// Draw the sky
setColor(new Color(0x00, 0xCC, 0xFF));

// Draw the sun
sun = new MySun();
sun.place(this);
/*
// Draw a setting sun
sun = new MySun(320, 80, new Color(0xFF, 0x33, 0x33));
sun.place(this);
*/
// Draw some grass
ARectangle grass = new ARectangle(0, 100, 400, 200);
grass.setColor(new Color(0x00, 0x99, 0x00));
grass.setToFill();
grass.place(this);
// Draw a house
MyHouse house = new MyHouse(100, 50);
house.place(this);
// Refresh the window to show the scene
repaint();
}
}
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: identifier expected
 
Similar Threads
Why does it not show the new coordinates?!!??!!
overriding help
Help with project using graphics
Checkerboard w/ 64 squares
Can't draw on JFrame or its ContentPane.