01.05.2013 Views

[P] Programming

[P] Programming

[P] Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

line.class contains the following member programs:<br />

class — Class programming 27<br />

.set program to set .c0 and .c1<br />

.c0.set program to set .c0<br />

.c1.set program to set .c1<br />

.length program to return length of line<br />

.midpoint program to return coordinate of midpoint of line<br />

.set, .length, and .midpoint came from line.class. .c0.set and .c1.set came from<br />

coordinate.class.<br />

Member program .length returns the length of the line.<br />

.len = .li.length<br />

would create .len containing the result of .li.length. The result of running the program .length<br />

on the object .li. .length returns a double, and therefore, .len will be a double.<br />

.midpoint returns the midpoint of a line.<br />

.mid = .li.midpoint<br />

would create .mid containing the result of .li.midpoint, the result of running the program<br />

.midpoint on the object .li. .midpoint returns a coordinate, and therefore, .mid will be a<br />

coordinate.<br />

2. Definitions<br />

2.1 Class definition<br />

Class classname is defined in file classname.class. The definition does not create any instances<br />

of the class.<br />

The classname.class file has three parts:<br />

version . . . // Part 1: version statement<br />

class classname { // Part 2: declaration of member variables<br />

. . .<br />

}<br />

program . . . // Part 3: code for member programs<br />

. . .<br />

end<br />

program . . .<br />

. . .<br />

end<br />

. . .<br />

2.2 Class instance<br />

To create a “variable” name of type classname, you type<br />

.name = .classname.new<br />

begin classname.class<br />

end classname.class

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!