| Author |
code is complete! but whats wrong here??
|
alaina peeler
Greenhorn
Joined: Dec 04, 2005
Posts: 29
|
|
|
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
Joined: Jul 08, 2003
Posts: 24040
|
|
|
Well, you'd have to show us the code, eh?
|
[Jess in Action][AskingGoodQuestions]
|
 |
alaina peeler
Greenhorn
Joined: Dec 04, 2005
Posts: 29
|
|
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
Joined: Mar 11, 2004
Posts: 62
|
|
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
Joined: Jan 29, 2006
Posts: 85
|
|
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.
|
 |
Ankur Sharma
Ranch Hand
Joined: Dec 27, 2005
Posts: 1234
|
|
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.
|
The Best way to predict your future is to create it
Ankur Sharma
|
 |
 |
|
|
subject: code is complete! but whats wrong here??
|
|
|