Home News DOC Class DL Others Cooker
Documents  >  Tutorial  >  Class definition
Class definition

Class definition is a set of member definitions that is described between the "class" and the "endclass". It decide statuses and behaviours of the class.


Table of contents:


Format

class

Class name

Member definition

endclass

Example

Format

The format of the class definition is:


"class" Class name

Member definitions

"endclass"


It is definition that start with the keyword class and end with the keyword endclass.

The class definition will generate a scope.

class

The keyword class is the start symbol for the class definition. Since it is a keyword, it cannot be used as an identifier.

Class name

It specifies the class name after "class". The naming rules for class name is the same as for identifiers.

Rice does not have a mechanism for avoiding class name collisions like namespaces in other languages.

For the class name, specify a unique name that does not conflict with other classes.

Member definition

Member definition are:


Field declaration

Fitter definition

Setter definition

Getter definition

Method definition


The field declaration determines the state of the class, and the other member definitions determine the behavior.

There is no limit to the order and number of member definitions.

Details of individual member definitions will be explained on a separate page.

endclass

The keyword endclass is the end symbol for the class definition. Since it is a keyword, it cannot be used as an identifier.

You can use the abbreviation "ec" instead of "endclass". Note that "ec" is also a keyword.

Example

As an example, definition of main class is reprinted. We've already mentioned that the main class is a special class, but it's definition is the same as any other user-defined class.

1:

class main

2:

open method void start()

3:

endmethod

4:

open method void end()

5:

endmethod

6:

ec // Abbreviation

It has defined the class name "main", the start() method, and the end() method.

Next
Previous
Copyright © Rice All rights reserved.