Solved

Cannot resolve symbol error. Please HELP!

Posted on 2003-11-02
18
517 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

839 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