.

Sunday, June 9, 2019

Modeling an Animal Class Hierarchy by Employing UML Diagrams Assignment

Modeling an Animal Class Hierarchy by Employing UML Diagrams - Assignment ExampleInheritance is an important belief in object-oriented programming. It not only serves as an organizational technique, but also allows code to be reused between classes that share certain characteristics. It is also known as Is A relationship because the classes down in the inheritance hierarchy are derived from the higher classes. So an object instantiated from a derived class is also a typecast of the superclass (Dale, Joyce, & Weems, 2006). Generalization and specialization are the two constituents of an inheritance relationship. The base class, from which the child classes are derived from, is supposed to be the more generic class and the child classes with supernumerary members are handed to be the more specialized classes (Thampi, 2009). For example, a dog class can be considered as a sub class of an animal class. In this case the animal class is more generic class and the dog class is the speci alized version of the animal class. To construct the animal class hierarchy, we consider the classes Animal, Fish, mammal, Shark, Herring, Elephant and Rodent. Animal is modeled as the base class from which all the other classes inherit either manoeuverly or indirectly. Fish and Mammal classes are the direct child classes derived from the Animal class. Sharks and herring are types of fishes and hence we can derive these classes from the Fish class. Similarly elephants and rodents are both mammals and hence they can be derived from the Mammal class.

No comments:

Post a Comment