public abstract class Shape
{
protected String name;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public abstract double getSurfaceArea();
protected double normalize(double entry)
{
if (entry < 0)
return 0.0;
else
return entry;
}
public String toString()
{
return getName() + "surface area: " + getSurfaceArea();
}
}
public class Square extends Shape
{
double length;
public Square(double length)
{
this.length = length;
}
public double getSurfaceArea()
{
double squareSurfaceArea = length * length;
return squareSurfaceArea;
}
}
Anyone have any idea why the memory address would print out? I want the ToString method to print out but I can't seem to figure out the problem.
EDIT: Now it is printing out nullSurfaceArea: and then the correct number but I don't understand why it is printing out null.
This post has been edited by tkess17: 21 February 2012 - 12:18 PM

New Topic/Question
Reply



MultiQuote






|