I do not know if I am on the right track or not, but I have hit a dead end. I have read and reread my books chapters about super classes and inheritance and am still completely lost. in this assignment I have to: Write a super class encapsulating a circle; this class has one attribute representing the radius of the circle. it has methods returning the perimeter and the area of the circle. This class has a subclass encapsulating a cylinder. A cylinder has a circle as its base and another attribute, its length; it has two methods, calculating and returning its area and volumes.
I am wondering if any one could help make sure I am on the right track and give me some advice on what I need to do to finish this as I am completely lost. I am a complete newbie with programimg and I have been working on this for 1 and 1/2 weeks and this is all i have. I also have no idea what needs to go in the Figure class. Thank You
first class
public class Question48
{
public static void main(String[] args)
{
Circle circle = new Circle();
System.out.println(circle.GetArea());
}
}
Second
public abstract class Figure
{
//Varibles
//constructor
public Figure()
{
}
}
Third
public class Circle extends Figure
{
//Varibles
double area;
double radius;
double perimeter;
public double setArea()
{
return area;
}
//accessors
public double GetArea()
{
return area;
}
public double GetPerimeter()
{
return perimeter;
}
public double getRadius()
{
return radius;
}
public Circle()
{
}
}
Fourth
public class Cylinder extends Circle
{
double length;
public double GetVolume()
{
return length * GetArea();
}
}