Class "Train" describes a simple toy train. Each of its objects keeps track of the color of the train and the number of its cars. Methods are available to modify these variables. The Java code for class "Train" is displayed. Methods that are being called are highlighted.
Class "RailRoad" has a main method in which objects of class "Train" are to be created and modified. In the applet the user gets the opportunity to create and modify objects by simple mouse clicks. These mouse clicks are translated into corresponding Java commands and displayed.
Method calls (also referred to as messages) are commonly qualified by parameters. In this applet the value of any such parameter can be chosen from a list of available ones before pressing the button that will result in the method call being issued. The same applies to constructors.
In object oriented programming languages method calls (messages) also have to specify the object on which they operate (recipient of the message). In this applet the object (recipient) is assumed to be the most recently created train unless otherwise specified ("Select the train:").