CSE 341 -- S. Tanimoto                                                                    Java Classes and Inheritance
6
Class Tetrahedron
public class Tetrahedron extends Polyhedron{
  // A constructor:
  Tetrahedron(double theWidth, double theLength, double theHeight) {
    width = theWidth; length = theLength; height = theHeight;
    nFaces = 4; nVertices = 4; nEdges = 6;
  }
  // A different concrete method for the same abstract method:
  public double volume() {
    return (width * length * height) / 6.0;
  }
  // This method overrides the parent’s, but calls it, too.
  public void describe() {
    System.out.print(“(Tetrahedron) “); super.describe();
  }
}