Purpose of this chapter.
We will learn about a minimum structure of the Rice program through a program that displays the "Hello World!".
Let's look at a code that outputs the "Hello world!".
open method void start()
When the above code is executed, it produces the following result.
Figure 1 : Hello world!
If there is no problem, a dialog should be displayed.
The above code has two important structures. Those are the class main and the start method.
Let's look at about those structures.
The class main is a class that serves as an interface between the application and the Rice. Therefore, class main is required for Rice program.
In the application, the execution of the Rice program is to invoke an open-method of class main. If the class main has not been properly defined, you cannot run the Rice program.
Let's look at the elements that make up the definition of the class main.
Figure 2 : elements of the class main definition.
The class keyword indicates the start of a class definition. It is required at the first of the class definition.
The class name is an identifier that is the name of the class being defined. It is necessary to immediately after the class keyword.
The endclass keyword indicates the end of the class definition. It is required at the end of the class definition.
start method definition
open-method of class main can be invoked from the application. Therefore, open-methods are available as a start method of the application.
start() method is special among the open-methods. It is the default start method of the Rice.
Let's look at the start method definition of the class main.
Figure 3 : start method definition.
The method definition begin from the designation of the access control. The access control determine the level of access. If the access control is open, the method will be accessible from the outside. If the access control is closed, it will be inaccessible from the outside.
The start method have to be specified the open because it is invoked from the application.
The method keyword indicates that it is a method definition. It has to be specified to the next of the access control.
The return type is designation of the return value type of the method. It has to be specified to the next of the method keyword.
The void is specified as the return type in the above start method. It indicates that the method does not return a value.
The return value type of default start method is optional. You can specify to return a specific type. However, it is meaningless because applications ignore the return value of the default start method.
The return type of the default start method should be specified the void (no return value).
The method name is an identifier that is the name of the method being defined. It has to be specified to the next of the return type.
The arguments is designation of a set of values that will be passed at the time of the method call. It has to be specified to the next of the method name. Also, it has to surround with a parenthesis.
In the above code, the inside of the parentheses is empty because default start method does not take any arguments.
A variable of the message class has been declared in order to display the dialog. Its name (identifier) is "m".
The message class is a embedded class of the Cooker. It has been implemented in C#. The message class returns an initialized instance in the declaration. Therefore, initialization of instance does not required.
MessageDialog(string) method of the message class is invoked, and a dialogbox is displayed.
The endmethod keyword indicates the end of the method definition. It has to be specified at the end of the method definition.