Development of the Tutorial examples
- Example 1-Implementing a simple class with one
method
Prints a default message when the "sayHello" method is invoked on an object
of the "Hello" class.
- Example 2-Adding an attribute to the Hello class
Defines a "msg" attribute for the "sayHello" method to use. The client program
"sets" a message; then the "sayHello" method "gets" the message and prints
it. (There is no defined message when an object of the "Hello" class is
first created.)
- Example 3- Overriding an inherited method
Overrides the SOMobjects method somPrintSelf so that invoking this
method on an object of the "Hello" class will not only display the class
name and the object's location, but will also include the object's message
attribute.
- Example 4-Initializing a SOM object.
Overrides the default initialization method, somDefaultInit, to
illustrate how an object's instance variables can be initialized when the
object is created.
- Example 5-Using multiple inheritance
Extends the "Hello" class to provide it with multiple inheritance (from
the "Disk;" and "Printer" classes.) The "Hello" interface defines an enum
and an "output" attribute that takes its value from the enum (either "screen,"
"printer," or "disk"). The client program "sets" the form of "output" before
invoking the "sayHello" method to send a "msg"(defined as in Example 4).
[Back: Basic Concepts of the System Object Model (SOM)]
[Next: Basic Steps for Implementing SOM Classes]