// Fig. 9.15: Cylinder.java
// Cylinder class inherits from Circle4.

public class Cylinder extends Circle4 {
   private double height;  // Cylinder's height

   // no-argument constructor
   public Cylinder()
   {
      // implicit call to Circle4 constructor occurs here
   } 

   // constructor
   public Cylinder( int xValue, int yValue, double radiusValue,
      double heightValue )
   {
      super( xValue, yValue, radiusValue ); // call Circle4 constructor
      setHeight( heightValue );
   } 

   // set Cylinder's height
   public void setHeight( double heightValue )
   {
      height = ( heightValue < 0.0 ? 0.0 : heightValue );
   } 

   // get Cylinder's height
   public double getHeight()
   {
      return height;
   } 

   // override Circle4 method getArea to calculate Cylinder area
   public double getArea()
   {
      return 2 * super.getArea() + getCircumference() * getHeight();
   } 

   // calculate Cylinder volume
   public double getVolume()
   {
      return super.getArea() * getHeight();
   } 

   // return String representation of Cylinder object
   public String toString()
   {
      return super.toString() + "; Height = " + getHeight();
   } 
	
} // end class Cylinder

/**************************************************************************
 * (C) Copyright 1992-2003 by Deitel & Associates, Inc. and               *
 * Prentice Hall. All Rights Reserved.                                    *
 *                                                                        *
 * DISCLAIMER: The authors and publisher of this book have used their     *
 * best efforts in preparing the book. These efforts include the          *
 * development, research, and testing of the theories and programs        *
 * to determine their effectiveness. The authors and publisher make       *
 * no warranty of any kind, expressed or implied, with regard to these    *
 * programs or to the documentation contained in these books. The authors *
 * and publisher shall not be liable in any event for incidental or       *
 * consequential damages in connection with, or arising out of, the       *
 * furnishing, performance, or use of these programs.                     *
 *************************************************************************/
