Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

identifier expected

 
Rob Michaelson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Rob Michaelson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic