In this chapter we went through the process of developing a class hierarchy. The example we chose was to create a hierarchy of classes that model a gas mixture. The first step was to think about what we were modeling, about the state and behavior of a gas mixture. Then we mapped out the general structure of our class hierarchy determining which classes would be subclasses of which other classes and so on. We then implemented the classes in the hierarchy and tested our work with three driver programs. The class hierarchies we developed are easily expandable. A new gas mixture or species class only needs to load the required data for the gas mixture or species and call the appropriate superclass constructor. The subclasses inherit all other functionality that they need from their superclasses. Now that we have developed gas mixture classes, what can we do with them? There are many applications in science and engineering, from modeling chemical processes to computing heat transfer on the surface of a spacecraft entering a planetary atmosphere to performing aerodynamic analyses. A well-designed Java class will often be useful for a wide variety of applications, and this quality is one of the powerful advantages of object-oriented programming. |