Solved

Cannot resolve symbol error. Please HELP!

Posted on 2003-11-02
18
510 Views
Last Modified: 2010-03-31
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;
}
}
0
Comment
Question by:brassmon
  • 8
  • 6
  • 4
18 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9667071
There is no setDepth method defined in your class
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 9667079
public void setDepth(double depth)
{
     this.depth = depth;
}
0
 
LVL 92

Expert Comment

by:objects
ID: 9667311
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();
}
}
0
 
LVL 15

Expert Comment

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

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20784472.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;
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9667446
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.
0
 
LVL 92

Expert Comment

by:objects
ID: 9667468
Storing depth as a member variable is redundant anyway, and probably should be removed as I outlined above.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9667530
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.
0
 
LVL 92

Expert Comment

by:objects
ID: 9667547
> 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 :)

0
 
LVL 15

Expert Comment

by:jimmack
ID: 9670116
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.

;-)
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 15

Expert Comment

by:jimmack
ID: 9670172
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 :-(
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9670826
If you've answered the question elsewhere the points may well come your way in good time - one way or another
0
 
LVL 92

Expert Comment

by:objects
ID: 9674679
Even worse when the wrong answer gets accepted.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9674900
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.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9674918
>>
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.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9674933
Thanks CEHJ.  So long as I know, I'm OK with it :-)
0
 
LVL 92

Expert Comment

by:objects
ID: 9674934
> 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.
0
 
LVL 92

Expert Comment

by:objects
ID: 9674959
> 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 ;)

0
 
LVL 15

Expert Comment

by:jimmack
ID: 9674970
Thanx objects.  Same applies again:

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now