• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code is complete! but whats wrong here??

 
alaina peeler
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an abstract class of Shapes and 3 child classes ....Shapes constructor is Shape(double mycircumference, double myarea)....in my child class im using super(my_side*4,my_side*my_side) but its saying cannot find constructor shapes(double,double)??
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you'd have to show us the code, eh?
 
alaina peeler
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public abstract class Shapes
{
protected double area, circumference;

public void Shape(double myCircumference, double myArea)
{
this.circumference=myCircumference;
this.area=myArea;
}

public String toString()
{
String result="Circumference: " + circumference + "/n" + "Area: " + area;
return result;

}
public abstract double Compute_area();

public abstract double Compute_circumference();

}
public class Square extends Shapes
{
private double side;

public Square(double my_side)
{
super(my_side * 4, my_side*my_side);//error here...cannot find symbol..constructor Shapes(double,double)
side=my_side;

}
public double Compute_circumference()
{
return circumference;
}
public double Compute_area()
{
return area;
}
public class Rectangle extends Shapes
{
private double width,height;

public Rectangle(double my_width,double my_height)//error here..cannot find symbol..constructor Shapes(double,double)

{
super(my_width*my_height, 2*my_width+my_height);
width=my_width;
height=my_height;
}
public double Compute_circumference()
{
return circumference;
}
public double Compute_area()
{
return area;
}

}
public class Circle extends Shapes
{
private double radius;

public Circle(double my_radius)
{
super(2*Math.PI*my_radius, my_radius*my_radius*Math.PI);//error here...cannot find symbol..constructor Shapes(double,double)

radius=my_radius;
}
public double Compute_circumference()
{
return circumference;
}
public double Compute_area()
{
return area;
}

}
 
Jeremy Tartaglia
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an abstract class of Shapes and 3 child classes ....Shapes constructor is Shape(double mycircumference, double myarea)....in my child class im using super(my_side*4,my_side*my_side) but its saying cannot find constructor shapes(double,double)??

Code wasn't necessary. Listen to what you're saying:

i have an abstract class of Shapes...Shapes constructor is Shape(double mycircumference, double myarea)...

Rule: The constructor name must be the same as the class name. The constructor is what gets called when you make a new object.

EDIT: Upon looking at the code, I noticed something else. Constructor methods do not return void. They don't return anything. Just:


[ February 14, 2006: Message edited by: Jeremy Tartaglia ]
 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You should check your each constructor again. I think that the errors are derived from the constructor that you specify.
You should also specify the super method parameters in the constructor 's parameters.

Best wishes.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found that your abstract class name is Shapes and you have defined the constructer name is Shape which is different so thats why the error is coming I have corrected the code try this one. it's perfectly correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic