192: Mainline
In the program in Segment 178, you saw the
rating
method defined as follows for Movie
instances:
public static int rating (Movie m) {
return m.script + m.acting + m.direction;
}
You can transform rating
from a class method into an
instance method. Each instance method has
one special argument, called the target:
- The special argument's value is a class instance. The class instance's
class definition includes the definition of the instance method.
- The special argument does not appear in parentheses with other, ordinary
arguments. Instead, the special argument is joined, via the
field-selection operator, to the name of the instance method, in
a manner reminiscent of instance-variable references.