public class Pyramid extends ThreeDimensionalShape
{
    // attributes
	      double height;  // vertical height
			double base;    // side of the square forming base
			double angleHeight;
			
	/**
	*  explicit value constructor
	*  @param length of a side of the square base
	*  @height of the pyramid from point to base
	*
	*/		
	public Pyramid (double sideOfSquare, double verticalHeight)
	{
	    super ("Square Pyramid");
		 height = verticalHeight;
		 base = sideOfSquare;
	}
	
	/**
	*  private method to compute the area of a triangle given the base and the 
	*  vertical height.  It first finds the angle height which is used to compute
	*  the area of the triangle 
	*
	*  @return area of the triangular side of the square pyramid
	*/
	private double getTriangleArea ()
	{
	      double areaOfTriangle;
			
	      angleHeight =  Math.sqrt ((.5* base) * (.5*base) +
			                height*height);  // using the pythagorean theorem
		
	      areaOfTriangle = .5*base*angleHeight; //  1/2 * base * height

         return areaOfTriangle;
    }
	
	  /**
	  * method computes and returns the surface area of a square pyramid.
	  * it uses the Square class to compute the area of the base
	  * and the getTriangleArea method of this Pyramid class to
	  * carry out the computation.
	  *
	  * @return surface area of the square Pyramid
	  *
	  */
	  public double getSurfaceArea() 
	  {
			 Square mySquare;  
		    double surfaceArea;
	  	    double baseArea;
						
			mySquare = new Square(base); // instantiate Square object
  		   baseArea = mySquare.getArea();  // get the area of the Square
			 
			surfaceArea = this.getTriangleArea()*4 + baseArea; // 4* triangularArea + baseArea
			return surfaceArea;
		} 
			 
       /**
		 * method computes the volume of a square pyramid using the formula 
	    * 1/3 * areaOfBase * height - it uses the Square class to provide the
		 * area of the base
		 *  
		 *  @return the volume of the pyramid
		 */
		 public double getVolume()
	    {
	      Square mySquare;
			double baseArea, volume;
						
			mySquare = new Square(base);
  		   baseArea = mySquare.getArea();  // finds area of the square base
         volume = (1./3.)*baseArea*height;
	         
		   return volume;
	 }
           
} // end Pyramid			