We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Using Processing 2.2.1
class TTurtle {
float flDeg;
TPoint P;
...
TTurtle& CT (void) {
P.x = width / 2;
P.y = height / 2;
flDeg = 0.0;
return *this;
}
}
Line 6 - unexpected Token: TTurtle!
The idea about returning "this" is to use function calls separated with .
TTurtle T = new TTurtel...
T.CT().LT(45).FW(100);
instead of:
T.CT();
T.LT(45);
T.FW(100);
Why doesn't it work in java?
Answers
*
and&
operators don't act as pointer manipulators in Java.Take a look @ my Colour class in the link below:
https://forum.Processing.org/two/discussion/10362/help-with-a-multidimensional-array
Most of its methods return
this
. That is, most of them allow chaining calling. :ar!P.S.: Most folks would prefer to type in methods in all lowercase letters:
Rather than
T.CT().LT(45).FW(100);
, this 1:t.ct().lt(45).fw(100);
. 8->