Link to home
Start Free TrialLog in
Avatar of brassmon
brassmonFlag for United States of America

asked on

Cannot resolve symbol error. Please HELP!

Here is the error I have been receiving.  If someone could help me with this it would be greatly appreciated.

C:\Java\compositionCube.java:16: cannot resolve symbol
symbol  : method setDepth (double)
location: class compositionCube
      setDepth( side );
        ^
1 error

Tool completed with exit code 1

public class compositionCube
{
private double depth;
private compositionSquare square;

public compositionCube()
{
      this( 0.0, 0, 0);
}


public compositionCube( double side, int x, int y )
{
      square = new compositionSquare( side, x, y );
      setDepth( side );
}

public double area()
{
      return square.area() * 6;

}

//ACCESS FOR DEPTH
public double getDepth()
{
      return depth;

}

//GET SHAPE NAME
public String getName()
{
      return "Cube";
}

//ACCESSOR TO SQUARE'S VALUE FOR AREA
public double getSquareArea()
{

      return square.area();

}

//ACCESSOR TO SQUARE'S NAME
public String getSquareName()
{
      return square.getName();

}

//ACCESSOR TO SQUARE'S ACCESSOR TO POINT'S NAME
public String getSPointName()
{
      return square.getPointName();
}

//ACCESSOR TO SQUARE'S ACCESSOR TO POINT'S STRING VALUE
public String getSPointString()
{
      return square.getPointString();

}

//ACCESSOR TO SQUARE'S STRING VALUE
public String getSquareString()
{
      return square.toString();

}

//RETURN A STRING DESCRIBING THE CUBE
public String toString()
{
return square.toString() + "; Depth = " + depth;
}

//CALCULATE VOLUME
public double volume()
{
return square.area() * depth;
}
}
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

There is no setDepth method defined in your class
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you only need it in your ctor (which appears to be the case) then just set your depth variable directly.

public compositionCube( double side, int x, int y )
{
     square = new compositionSquare( side, x, y );
     this.side = side;
}

Though I'd question whether you even need to store depth as it is already stored in your square. You could instead do:

public class compositionCube
{
private compositionSquare square;

public compositionCube()
{
     this( 0.0, 0, 0);
}


public compositionCube( double side, int x, int y )
{
     square = new compositionSquare( side, x, y );
}

public double area()
{
     return square.area() * 6;

}

//ACCESS FOR DEPTH
public double getDepth()
{
     return square.getSide();

}

//GET SHAPE NAME
public String getName()
{
     return "Cube";
}

//ACCESSOR TO SQUARE'S VALUE FOR AREA
public double getSquareArea()
{

     return square.area();

}

//ACCESSOR TO SQUARE'S NAME
public String getSquareName()
{
     return square.getName();

}

//ACCESSOR TO SQUARE'S ACCESSOR TO POINT'S NAME
public String getSPointName()
{
     return square.getPointName();
}

//ACCESSOR TO SQUARE'S ACCESSOR TO POINT'S STRING VALUE
public String getSPointString()
{
     return square.getPointString();

}

//ACCESSOR TO SQUARE'S STRING VALUE
public String getSquareString()
{
     return square.toString();

}

//RETURN A STRING DESCRIBING THE CUBE
public String toString()
{
return square.toString() + "; Depth = " + getDepth();
}

//CALCULATE VOLUME
public double volume()
{
return square.area() * getDepth();
}
}
Avatar of jimmack
jimmack

brassmon.  I've already answered this for you too.  Please read my comments on your previous posting 10/31/2003

https://www.experts-exchange.com/questions/20784472/Composition-Cube-Problems.html

>>It doesn't compile (for the following reasons):
>>
.
.
.
>>2) Again the the compositionCube constructor, this class doesn't have a setDepth method.
>>
>>        depth = side;
CEHJ and objects - sorry to chop in again.  I'm not sure why brassmon hasn't responded to the solution I posted in the above reference.

Jim.
Storing depth as a member variable is redundant anyway, and probably should be removed as I outlined above.
Hi objects ;-)  That's fair comment (and I confess, I didn't read your full posting :-( )

I'm just a bit concerned that brassmon has asked three such closely related questions, but doesn't seem to be commenting on the responses.
> I'm just a bit concerned that brassmon has asked three such closely
> related questions, but doesn't seem to be commenting on the
> responses.

Happens all the time :)

I hope this doesn't happen all the time objects :-(

I must confess, although I'm unhappy about not getting the points, I'm almost as keen to see you hit 1,000,000 as I am to get my first certification level at Master.

Almost ;-)


CEHJ: You.. you.. you.. points absorber, you.

;-)
This is nagging at me, so objects and CEHJ, can I ask your advice?

The last thing I want to do is upset either of you.  You both know your stuff (*big time*) and you have both provided good answers.  What would you both do in this situation?

I'll swallow the bitter pill ;-) I just feel a bit short changed :-(
If you've answered the question elsewhere the points may well come your way in good time - one way or another
Even worse when the wrong answer gets accepted.
Well, thanks for your comments (I think).

CEHJ: Are you implying that you will take action on this or is this a reference to "all good things to he who waits"?

objects: Is this a general comment or are you implying that I've had an answer accepted when it should have been yours?

As I said, I'm not here to upset anyone, I'm here to help - where I can.

So... If I've done something wrong, tell me so I don't do it again.  If you're both happy with the way the points were handled, tell me so I know where I stand.

Thanx.

Jim.
>>
CEHJ: Are you implying that you will take action on this or is this a reference to "all good things to he who waits"?
>>

The latter. I'm unaware of your previous history elsewhere with this question. As far as the question is concerned here, the problem, and the solution, which I gave, were both very clear.
Thanks CEHJ.  So long as I know, I'm OK with it :-)
> Is this a general comment or ...

Just a general comment :)

> If you're both happy with the way the points were handled

How the points are handled is up to the asker. We are just here to provide answers.
> and the solution, which I gave, were both very clear.

Though a little error-prone as a call to setDepth() may result in the cube no longer being a cube ;)

Thanx objects.  Same applies again:

>> So long as I know, I'm OK with it :-)