Advertisement
RazorBlade57

CircleSubclass

Feb 20th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public class Cylinder extends Circle {
  2.    private double height;
  3.  
  4.    public Cylinder() {
  5.       super.Circle();
  6.        }
  7.  
  8.    public Cylinder(double height) {
  9.      super.Circle(height);
  10.    }
  11.  
  12.    public Cylinder(double radius, double height) {
  13.      super.Circle(radius, height);
  14.      
  15.    }
  16.    
  17.    public double getHeight() {
  18.       return  height;
  19.    }
  20.  
  21.    public double getVolume() {
  22.       return  getArea()*height;
  23.    }
  24.  
  25.    @Override
  26.    public String toString() {
  27.         return "Cylinder: subclass of " + Circle.toString();
  28.           + " height=" + height;
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement