Skip to main content
deleted 104 characters in body
Source Link
Sotirios Delimanolis
  • 281k
  • 62
  • 718
  • 744

I'm having no luck calling a variable from my superclass to my subclass. Can anyone help out?

//SUPERCLASS public class Circle { protected double radius; protected double area; //Some code to construct object and initialize radius //Return Calculated Area protected double getArea() { area = Math.pow(radius, 2) * Math.PI; return area; } } //SUBCLASS public class Cone extends Circle { private double height; //Some more code with constructors and different methods public double getVolume() { { return (area * height / 3) } }

//SUPERCLASS public class Circle { protected double radius; protected double area; //Some code to construct object and initialize radius //Return Calculated Area protected double getArea() { area = Math.pow(radius, 2) * Math.PI; return area; } } //SUBCLASS public class Cone extends Circle { private double height; //Some more code with constructors and different methods public double getVolume() { { return (area * height / 3) } } 

There is a lot more to the code but the main problem I'm having is within the subclass, the 'area' variable is 0.00 and I'm unsure how to get it equal to the 'area' that is calculated in the superclass

I'm having no luck calling a variable from my superclass to my subclass. Can anyone help out?

//SUPERCLASS public class Circle { protected double radius; protected double area; //Some code to construct object and initialize radius //Return Calculated Area protected double getArea() { area = Math.pow(radius, 2) * Math.PI; return area; } } //SUBCLASS public class Cone extends Circle { private double height; //Some more code with constructors and different methods public double getVolume() { { return (area * height / 3) } }

There is a lot more to the code but the main problem I'm having is within the subclass, the 'area' variable is 0.00 and I'm unsure how to get it equal to the 'area' that is calculated in the superclass

I'm having no luck calling a variable from my superclass to my subclass. Can anyone help out?

//SUPERCLASS public class Circle { protected double radius; protected double area; //Some code to construct object and initialize radius //Return Calculated Area protected double getArea() { area = Math.pow(radius, 2) * Math.PI; return area; } } //SUBCLASS public class Cone extends Circle { private double height; //Some more code with constructors and different methods public double getVolume() { { return (area * height / 3) } } 

There is a lot more to the code but the main problem I'm having is within the subclass, the 'area' variable is 0.00 and I'm unsure how to get it equal to the 'area' that is calculated in the superclass

Source Link

Calling variable to subclass from superclass

I'm having no luck calling a variable from my superclass to my subclass. Can anyone help out?

//SUPERCLASS public class Circle { protected double radius; protected double area; //Some code to construct object and initialize radius //Return Calculated Area protected double getArea() { area = Math.pow(radius, 2) * Math.PI; return area; } } //SUBCLASS public class Cone extends Circle { private double height; //Some more code with constructors and different methods public double getVolume() { { return (area * height / 3) } }

There is a lot more to the code but the main problem I'm having is within the subclass, the 'area' variable is 0.00 and I'm unsure how to get it equal to the 'area' that is calculated in the superclass