[SATCOM] Rewrite "class"
parent
faebc8f4bc
commit
ea32d482c5
|
@ -1,72 +1,122 @@
|
|||
\b;Instruction \c;class\n;
|
||||
This allows you to declare a class definition using following syntax:
|
||||
This keyword allows you to create a class definition by using the following syntax:
|
||||
\c;
|
||||
\s;public class ClassName
|
||||
\s;{
|
||||
\s; declarations;
|
||||
\s;}
|
||||
\n;
|
||||
Classes can only be \l;public\u cbot\public;, that is they can be used from all bots in a mission. Class members are also public, that is they are accessible from outside the class. Class members can be fields or functions (also called methods), for example the followin class \c;MyClass\n; contains 4 fields (a, b, x and s) and one method (MyFunction).
|
||||
\t;All Classes Are Public
|
||||
Classes can be only \l;public\u cbot\public;. This means that they can be used by all bots in a mission.
|
||||
|
||||
\b;Class Members
|
||||
Class members are fields (\l;variables\u cbot\var;) and methods (\l;functions\u cbot\function;).
|
||||
|
||||
For example, the following class dubbed \c;MyClass\n; contains 4 fields (\c;a\n;, \c;b\n;, \c;x\n; and \c;s\n;) and one method (\c;MyFunction\n;).
|
||||
\c;
|
||||
\s;public class MyClass
|
||||
\s;{
|
||||
\s; int a, b;
|
||||
\s; float x = 3.33;
|
||||
\s; string s = "hello";
|
||||
\s; float MyFunction( float value )
|
||||
\s; float MyFunction(float value)
|
||||
\s; {
|
||||
\s; return (value*x)-1;
|
||||
\s; return (value * x) - 1;
|
||||
\s; }
|
||||
\s;}
|
||||
\n;
|
||||
As shown in this exemple the class members can be initialized (\c;x=3.33\n;). You can also define a constructor which is a special method having the same name as the class name. This method will be called automatically at creation time of a class instance. You can also declare more than one method with the same name but different parameters.
|
||||
\b;Accessing Class Members
|
||||
Class members can be accessed outside of the class definition by using the \c;.\n; operator. Example:
|
||||
\c;
|
||||
\s;public class MyClass
|
||||
\s;{
|
||||
\s; int myField = 0;
|
||||
\s; int MyFunction()
|
||||
\s; {
|
||||
\s; return myField * 2;
|
||||
\s; }
|
||||
\s;}
|
||||
\s;
|
||||
\s;extern void object::Test()
|
||||
\s;{
|
||||
\s; MyClass myObject();
|
||||
\s; myObject.myField = 10;
|
||||
\s; message(myObject.MyFunction()); // 20
|
||||
\s; MyClass mySecondObject();
|
||||
\s; mySecondObject.myField = myObject.myField - 2;
|
||||
\s; message(mySecondObject.MyFunction()); // 16
|
||||
\s;}
|
||||
\n;
|
||||
Class members are \l;public\u cbot\public; by default, which means that they are accessible outside of the class definition. They can also be declared as \c;\l;private\u cbot\private;\n; or \c;\l;protected\u cbot\protected;\n;. Such members can only be accessed inside of the class definition.
|
||||
|
||||
\t;Class Members Modifiers
|
||||
Fields and methods can also be declared as \c;\l;static\u cbot\static;\n;. Methods can be additionaly declared as \c;\l;synchronized\u cbot\synchro;\n;.
|
||||
|
||||
\t;Member Initialization
|
||||
As shown in the previous exemple, the class members can be initialized in the class definition (\c;int x = 3.33;\n;).
|
||||
|
||||
Another way of initiliazing fields is by defining a constructor which is a special method having the same name as the class. This method will be called automatically at \l;creation\u cbot\new; time of a class instance. Constructors can be \l;overloaded\u cbot\function;.
|
||||
|
||||
Example:\c;
|
||||
\s;public class MyClass
|
||||
\s;{
|
||||
\s; int a, b;
|
||||
\s; void MyClass( )
|
||||
\s; void MyClass()
|
||||
\s; {
|
||||
\s; a = 2; b = 3;
|
||||
\s; }
|
||||
\s; void MyClass( int a, int b )
|
||||
\s; void MyClass(int a, int b)
|
||||
\s; {
|
||||
\s; this.a = a; this.b = b;
|
||||
\s; }
|
||||
\s;}
|
||||
\n;
|
||||
In this example two constructors are declared for \c;MyClass\n;, one without parameters and the other one with two parameters. As the names of the parameters of the second constructor are the same as the names of the two members \c;a\n; et \c;b\n; we must use the \c;\l;this\u cbot\this;.a\n; and \c;\l;this\u cbot\this;.b\n; to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters.
|
||||
|
||||
\t;Using \c;\l;this\u cbot\this;\n;
|
||||
As the names of the parameters of the second constructor are the same as the names of the two members \c;a\n; and \c;b\n;, we must use the \c;\l;this\u cbot\this;\n; \l;reference\u cbot\pointer; to avoid confusion with the parameters' names.
|
||||
|
||||
\b;Object Creation
|
||||
You can create objects of type \c;YourClass\n; using the \c;\l;new\u cbot\new;\n; keyword. Example:
|
||||
\c;
|
||||
\s;void Test( )
|
||||
\s;extern void object::Test()
|
||||
\s;{
|
||||
\s; MyClass item1(); // constr. w/o parameters
|
||||
\s; MyClass item2(4, 5); // constr. with 2 parameters
|
||||
\s; MyClass item3; // no constructor called,
|
||||
\s; // therefore item3 == null
|
||||
\s; MyClass object1(); // Call default constructor (without parameters)
|
||||
\s; MyClass object2(4, 5); // Call constructor with two int parameters
|
||||
\s; MyClass object3; // No constructor called, object3 == null
|
||||
\s; object3 = new MyClass(); // We call constructor now, object3 != null
|
||||
\s;}
|
||||
\n;
|
||||
You can also define a destructor. This must be a \c;void\n; fonction without parameters that has the same name as the class name but prefixed by the ~ character. The destructor is called automatically as soon as the class instance is no more referenced by anyone.
|
||||
|
||||
\b;Object Destruction
|
||||
You can also define a destructor. This must be a \c;\l;void\u cbot\void;\n; fonction without parameters, which has the same name as the class but prefixed with the \c;~\n; character. The destructor is called automatically as soon as the class instance is no more referenced by anyone. Example:
|
||||
\c;
|
||||
\s;public class MyClass
|
||||
\s;{
|
||||
\s; static private int counter = 0; // instance counter
|
||||
\s; void MyClass( )
|
||||
\s; {
|
||||
\s; counter ++; // one instance more
|
||||
\s; counter++; // one instance more
|
||||
\s; }
|
||||
\s; void ~MyClass( )
|
||||
\s; {
|
||||
\s; counter --; // one instance less
|
||||
\s; counter--; // one instance less
|
||||
\s; }
|
||||
\s;}
|
||||
\s;void Test()
|
||||
\s;extern void object::Test()
|
||||
\s;{
|
||||
\s; MyClass item1( ); // counter = 1
|
||||
\s; MyClass item2( ); // counter = 2
|
||||
\s; item1 = null; // counter = 1
|
||||
\s;} // counter = 0
|
||||
\s; // counter == 0
|
||||
\s; MyClass item1( ); // counter == 1
|
||||
\s; MyClass item2( ); // counter == 2
|
||||
\s; item1 = null; // counter == 1
|
||||
\s;}
|
||||
\s;// counter == 0
|
||||
\n;
|
||||
If you pass a class instance as parameter to a \l;function\u cbot\function;, the function only receives a \l;reference\u cbot\pointer; to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified.
|
||||
\b;Passing Objects to Functions
|
||||
Objects in CBOT are passed by \l;reference\u cbot\pointer;. This means that when an object is passed to a \l;function\u cbot\function;, the function receives a copy of a pointer to the instance, not a copy of the object, so any modifications on the object will be visible outside of the function.
|
||||
|
||||
\b;Inheritance
|
||||
A class can inherit public and protected members of another class by using the \c;\l;extends\u cbot\extends;\n; keyword.
|
||||
|
||||
\t;See also
|
||||
\c;\l;public\u cbot\public;\n;, \c;\l;private\u cbot\private;\n;, \c;\l;static\u cbot\static;\n;, \c;\l;synchronized\u cbot\synchro;\n;, \c;\l;new\u cbot\new;\n;, \c;\l;reference\u cbot\pointer;\n;, \c;\l;this\u cbot\this;\n;
|
||||
\c;\l;public\u cbot\public;\n;, \c;\l;private\u cbot\private;\n;, \c;\l;protected\u cbot\protected;\n;, \c;\l;static\u cbot\static;\n;, \c;\l;synchronized\u cbot\synchro;\n;, \c;\l;new\u cbot\new;\n;, \c;\l;reference\u cbot\pointer;\n;, \c;\l;this\u cbot\this;\n;, \c;\l;super\u cbot\super;\n;, \c;\l;extends\u cbot\extends;\n;
|
||||
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.
|
||||
|
|
|
@ -53,7 +53,7 @@ msgid "Time in seconds."
|
|||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:120 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr ""
|
||||
|
@ -478,12 +478,6 @@ msgstr ""
|
|||
msgid "Instruction <code>class</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This allows you to declare a class definition using following syntax:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:4
|
||||
#, no-wrap
|
||||
|
@ -494,115 +488,6 @@ msgid ""
|
|||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "Classes can only be <a cbot|public>public</a>, that is they can be used from all bots in a mission. Class members are also public, that is they are accessible from outside the class. Class members can be fields or functions (also called methods), for example the followin class <code>MyClass</code> contains 4 fields (a, b, x and s) and one method (MyFunction)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:11
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:22
|
||||
#, no-wrap
|
||||
msgid "As shown in this exemple the class members can be initialized (<code>x=3.33</code>). You can also define a constructor which is a special method having the same name as the class name. This method will be called automatically at creation time of a class instance. You can also declare more than one method with the same name but different parameters."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:24
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:37
|
||||
#, no-wrap
|
||||
msgid "In this example two constructors are declared for <code>MyClass</code>, one without parameters and the other one with two parameters. As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> et <code>b</code> we must use the <code><a cbot|this>this</a>.a</code> and <code><a cbot|this>this</a>.b</code> to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:39
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMyClass item1(); // constr. w/o parameters\n"
|
||||
"\tMyClass item2(4, 5); // constr. with 2 parameters\n"
|
||||
"\tMyClass item3; // no constructor called,\n"
|
||||
" // therefore item3 == null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:47
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code>void</code> fonction without parameters that has the same name as the class name but prefixed by the ~ character. The destructor is called automatically as soon as the class instance is no more referenced by anyone."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:49
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass item1( ); // counter = 1\n"
|
||||
"\tMyClass item2( ); // counter = 2\n"
|
||||
"\titem1 = null; // counter = 1\n"
|
||||
"} // counter = 0"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:68
|
||||
#, no-wrap
|
||||
msgid "If you pass a class instance as parameter to a <a cbot|function>function</a>, the function only receives a <a cbot|pointer>reference</a> to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:71
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/close.txt:1
|
||||
#, no-wrap
|
||||
|
@ -7548,3 +7433,258 @@ msgid ""
|
|||
" <code><a object|target1>Target1</a> </code>Flying target\n"
|
||||
" <code><a object|nest>AlienNest</a> </code>Alien Nest"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:10
|
||||
#, no-wrap
|
||||
msgid "Classes can be only <a cbot|public>public</a>. This means that they can be used by all bots in a mission."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:12
|
||||
#, no-wrap
|
||||
msgid "Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:13
|
||||
#, no-wrap
|
||||
msgid "Class members are fields (<a cbot|var>variables</a>) and methods (<a cbot|function>functions</a>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:15
|
||||
#, no-wrap
|
||||
msgid "For example, the following class dubbed <code>MyClass</code> contains 4 fields (<code>a</code>, <code>b</code>, <code>x</code> and <code>s</code>) and one method (<code>MyFunction</code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:17
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction(float value)\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value * x) - 1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:55
|
||||
#, no-wrap
|
||||
msgid "Member Initialization"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:60
|
||||
#, no-wrap
|
||||
msgid "Example:<c/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:61
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass()\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass(int a, int b)\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:76
|
||||
#, no-wrap
|
||||
msgid "As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> and <code>b</code>, we must use the <code><a cbot|this>this</a></code> <a cbot|pointer>reference</a> to avoid confusion with the parameters' names."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:78
|
||||
#, no-wrap
|
||||
msgid "Object Creation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:79
|
||||
#, no-wrap
|
||||
msgid "You can create objects of type <code>YourClass</code> using the <code><a cbot|new>new</a></code> keyword. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:90
|
||||
#, no-wrap
|
||||
msgid "Object Destruction"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:114
|
||||
#, no-wrap
|
||||
msgid "Passing Objects to Functions"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:115
|
||||
#, no-wrap
|
||||
msgid "Objects in CBOT are passed by <a cbot|pointer>reference</a>. This means that when an object is passed to a <a cbot|function>function</a>, the function receives a copy of a pointer to the instance, not a copy of the object, so any modifications on the object will be visible outside of the function."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:117
|
||||
#, no-wrap
|
||||
msgid "Inheritance"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:118
|
||||
#, no-wrap
|
||||
msgid "A class can inherit public and protected members of another class by using the <code><a cbot|extends>extends</a></code> keyword."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This keyword allows you to create a class definition by using the following syntax:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "All Classes Are Public"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:52
|
||||
#, no-wrap
|
||||
msgid "Class Members Modifiers"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:75
|
||||
#, no-wrap
|
||||
msgid "Using <code><a cbot|this>this</a></code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:81
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass object1(); // Call default constructor (without parameters)\n"
|
||||
"\tMyClass object2(4, 5); // Call constructor with two int parameters\n"
|
||||
"\tMyClass object3; // No constructor called, object3 == null\n"
|
||||
"\tobject3 = new MyClass(); // We call constructor now, object3 != null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:91
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code><a cbot|void>void</a></code> fonction without parameters, which has the same name as the class but prefixed with the <code>~</code> character. The destructor is called automatically as soon as the class instance is no more referenced by anyone. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:93
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter--; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\t // counter == 0\n"
|
||||
"\tMyClass item1( ); // counter == 1\n"
|
||||
"\tMyClass item2( ); // counter == 2\n"
|
||||
"\titem1 = null; // counter == 1\n"
|
||||
"}\n"
|
||||
"// counter == 0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:28
|
||||
#, no-wrap
|
||||
msgid "Accessing Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:29
|
||||
#, no-wrap
|
||||
msgid "Class members can be accessed outside of the class definition by using the <code>.</code> operator. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:50
|
||||
#, no-wrap
|
||||
msgid "Class members are <a cbot|public>public</a> by default, which means that they are accessible outside of the class definition. They can also be declared as <code><a cbot|private>private</a></code> or <code><a cbot|protected>protected</a></code>. Such members can only be accessed inside of the class definition."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:53
|
||||
#, no-wrap
|
||||
msgid "Fields and methods can also be declared as <code><a cbot|static>static</a></code>. Methods can be additionaly declared as <code><a cbot|synchro>synchronized</a></code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:56
|
||||
#, no-wrap
|
||||
msgid "As shown in the previous exemple, the class members can be initialized in the class definition (<c/>int x = 3.33;<n/>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:58
|
||||
#, no-wrap
|
||||
msgid "Another way of initiliazing fields is by defining a constructor which is a special method having the same name as the class. This method will be called automatically at <a cbot|new>creation</a> time of a class instance. Constructors can be <a cbot|function>overloaded</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:31
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint myField = 0;\n"
|
||||
"\tint MyFunction()\n"
|
||||
"\t{\n"
|
||||
"\t\treturn myField * 2;\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass myObject();\n"
|
||||
"\tmyObject.myField = 10;\n"
|
||||
"\tmessage(myObject.MyFunction()); // 20\n"
|
||||
"\tMyClass mySecondObject();\n"
|
||||
"\tmySecondObject.myField = myObject.myField - 2;\n"
|
||||
"\tmessage(mySecondObject.MyFunction()); // 16\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:121
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|protected>protected</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>, <code><a cbot|super>super</a></code>, <code><a cbot|extends>extends</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
|
|
@ -53,7 +53,7 @@ msgid "Time in seconds."
|
|||
msgstr "Zeit in Sekunden."
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:120 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "Siehe auch"
|
||||
|
@ -528,12 +528,6 @@ msgstr "Die <a cbot>CBOT-Sprache</a> und die <a cbot|type>Variablentypen</a>."
|
|||
msgid "Instruction <code>class</code>"
|
||||
msgstr "Anweisung <code>class</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This allows you to declare a class definition using following syntax:"
|
||||
msgstr "Mit dieser Anweisung können Sie eine Klasse deklarieren. Benutzen Sie folgende Syntax:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:4
|
||||
#, no-wrap
|
||||
|
@ -548,164 +542,6 @@ msgstr ""
|
|||
"\t<n/>Deklarationen<c/>;\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "Classes can only be <a cbot|public>public</a>, that is they can be used from all bots in a mission. Class members are also public, that is they are accessible from outside the class. Class members can be fields or functions (also called methods), for example the followin class <code>MyClass</code> contains 4 fields (a, b, x and s) and one method (MyFunction)."
|
||||
msgstr "Klassen können nur <a cbot|public>public</a> (öffentlich) definiert werden, das heißt, dass sie von allen Robotern der Mission benutzt werden können. Alle Glieder sind ebenfalls public, können also von außerhalb der Klasse benutzt werden. Glieder einer Klasse können Variablen oder Methoden (Funktionen) sein. Im folgenden Beispiel enthält die Klasse <code>MeineKlasse</code> vier Instanzvariablen (a, b, x und s) und eine Methode (MeineFunktion):"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:11
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MeineKlasse\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MeineFunktion( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:22
|
||||
#, no-wrap
|
||||
msgid "As shown in this exemple the class members can be initialized (<code>x=3.33</code>). You can also define a constructor which is a special method having the same name as the class name. This method will be called automatically at creation time of a class instance. You can also declare more than one method with the same name but different parameters."
|
||||
msgstr "Wie in diesem Beispiel gezeigt wird, können die Variablen einer Klasse initialisiert werden (z.B. <code>x=3.33</code>). Sie können auch einen Constructor definieren, das heißt eine Methode, die denselben Namen hat wie die Klasse. Diese Methode wird automatisch aufgerufen, wenn eine neue Instanz der Klasse erstellt wird. Sie können auch mehr als eine Methode mit demselben Namen, aber mit verschiedenen Parametern definieren:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:24
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MeineKlasse\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MeineKlasse ( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MeineKlasse( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:37
|
||||
#, no-wrap
|
||||
msgid "In this example two constructors are declared for <code>MyClass</code>, one without parameters and the other one with two parameters. As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> et <code>b</code> we must use the <code><a cbot|this>this</a>.a</code> and <code><a cbot|this>this</a>.b</code> to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters."
|
||||
msgstr "In diesem Beispiel wurden für <code>MeineKlasse</code> zwei Constructor-Methoden deklariert, eine ohne Parameter, und eine mit zwei Parametern. Da die Namen der Parameter der zweiten Methode dieselben Namen haben wie die Namen der zwei Instanzvariablen <code>a</code> und <code>b</code>, muss für eine Referenz auf die Instanzvariablen <code><a cbot|this>this</a>.a</code> und <code><a cbot|this>this</a>.b</code> geschrieben werden, um einer Verwechslung vorzubeugen. Einfacher wäre es natürlich, den Parametern andere Namen zu geben."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:39
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMyClass item1(); // constr. w/o parameters\n"
|
||||
"\tMyClass item2(4, 5); // constr. with 2 parameters\n"
|
||||
"\tMyClass item3; // no constructor called,\n"
|
||||
" // therefore item3 == null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMeineKlasse item1(); // Constr. ohne Parameter\n"
|
||||
"\tMeineKlasse item2(4, 5); // Constr. mit 2 Parametern\n"
|
||||
"\tMeineKlasse item3; // kein Constr. aufgerufen,\n"
|
||||
" // deshalb item3 == null\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:47
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code>void</code> fonction without parameters that has the same name as the class name but prefixed by the ~ character. The destructor is called automatically as soon as the class instance is no more referenced by anyone."
|
||||
msgstr "Sie können auch einen Destructor deklarieren. Die ist eine <code>void</code>-Funktion ohne Parameter, die denselben Namen wie die Klasse hat, der aber ein \"~\"-Zeichen vorangestellt wird. Dieser Destructor wird aufgerufen, sobald sich keine Variable mehr auf diese Instanz bezieht."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:49
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass item1( ); // counter = 1\n"
|
||||
"\tMyClass item2( ); // counter = 2\n"
|
||||
"\titem1 = null; // counter = 1\n"
|
||||
"} // counter = 0"
|
||||
msgstr ""
|
||||
"public class MeineKlasse\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0;// Zähler f. Instanzen\n"
|
||||
"\tvoid MeineKlasse( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // eine Instanz mehr\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MeineKlasse( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // eine Instanz weniger\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMeineKlasse item1( ); // counter = 1\n"
|
||||
"\tMeineKlasse item2( ); // counter = 2\n"
|
||||
"\titem1 = null; // counter = 1\n"
|
||||
"} // counter = 0"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:68
|
||||
#, no-wrap
|
||||
msgid "If you pass a class instance as parameter to a <a cbot|function>function</a>, the function only receives a <a cbot|pointer>reference</a> to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified."
|
||||
msgstr "Wenn Sie eine Klasseninstanz als Parameter an eine <a cbot|function>Funktion</a> übergeben, erhält die Funktion nur einen <a cbot|pointer>Zeiger</a> auf die Instanz. Wenn Sie also die der Funktion übergebene Instanz verändern, wird die Instanz selber verändert."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:71
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>Zeiger</a></code> und <code><a cbot|this>this</a></code>.\n"
|
||||
"Die <a cbot>CBOT-Sprache</a>, <a cbot|type>Variablentypen</a> und <a cbot|category>Kategorien</a>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/close.txt:1
|
||||
#, no-wrap
|
||||
|
@ -8306,3 +8142,258 @@ msgid ""
|
|||
" <code><a object|target1>Target1</a> </code>Flying target\n"
|
||||
" <code><a object|nest>AlienNest</a> </code>Alien Nest"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:10
|
||||
#, no-wrap
|
||||
msgid "Classes can be only <a cbot|public>public</a>. This means that they can be used by all bots in a mission."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:12
|
||||
#, no-wrap
|
||||
msgid "Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:13
|
||||
#, no-wrap
|
||||
msgid "Class members are fields (<a cbot|var>variables</a>) and methods (<a cbot|function>functions</a>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:15
|
||||
#, no-wrap
|
||||
msgid "For example, the following class dubbed <code>MyClass</code> contains 4 fields (<code>a</code>, <code>b</code>, <code>x</code> and <code>s</code>) and one method (<code>MyFunction</code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:17
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction(float value)\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value * x) - 1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:55
|
||||
#, no-wrap
|
||||
msgid "Member Initialization"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:60
|
||||
#, no-wrap
|
||||
msgid "Example:<c/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:61
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass()\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass(int a, int b)\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:76
|
||||
#, no-wrap
|
||||
msgid "As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> and <code>b</code>, we must use the <code><a cbot|this>this</a></code> <a cbot|pointer>reference</a> to avoid confusion with the parameters' names."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:78
|
||||
#, no-wrap
|
||||
msgid "Object Creation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:79
|
||||
#, no-wrap
|
||||
msgid "You can create objects of type <code>YourClass</code> using the <code><a cbot|new>new</a></code> keyword. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:90
|
||||
#, no-wrap
|
||||
msgid "Object Destruction"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:114
|
||||
#, no-wrap
|
||||
msgid "Passing Objects to Functions"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:115
|
||||
#, no-wrap
|
||||
msgid "Objects in CBOT are passed by <a cbot|pointer>reference</a>. This means that when an object is passed to a <a cbot|function>function</a>, the function receives a copy of a pointer to the instance, not a copy of the object, so any modifications on the object will be visible outside of the function."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:117
|
||||
#, no-wrap
|
||||
msgid "Inheritance"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:118
|
||||
#, no-wrap
|
||||
msgid "A class can inherit public and protected members of another class by using the <code><a cbot|extends>extends</a></code> keyword."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This keyword allows you to create a class definition by using the following syntax:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "All Classes Are Public"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:52
|
||||
#, no-wrap
|
||||
msgid "Class Members Modifiers"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:75
|
||||
#, no-wrap
|
||||
msgid "Using <code><a cbot|this>this</a></code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:81
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass object1(); // Call default constructor (without parameters)\n"
|
||||
"\tMyClass object2(4, 5); // Call constructor with two int parameters\n"
|
||||
"\tMyClass object3; // No constructor called, object3 == null\n"
|
||||
"\tobject3 = new MyClass(); // We call constructor now, object3 != null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:91
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code><a cbot|void>void</a></code> fonction without parameters, which has the same name as the class but prefixed with the <code>~</code> character. The destructor is called automatically as soon as the class instance is no more referenced by anyone. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:93
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter--; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\t // counter == 0\n"
|
||||
"\tMyClass item1( ); // counter == 1\n"
|
||||
"\tMyClass item2( ); // counter == 2\n"
|
||||
"\titem1 = null; // counter == 1\n"
|
||||
"}\n"
|
||||
"// counter == 0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:28
|
||||
#, no-wrap
|
||||
msgid "Accessing Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:29
|
||||
#, no-wrap
|
||||
msgid "Class members can be accessed outside of the class definition by using the <code>.</code> operator. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:50
|
||||
#, no-wrap
|
||||
msgid "Class members are <a cbot|public>public</a> by default, which means that they are accessible outside of the class definition. They can also be declared as <code><a cbot|private>private</a></code> or <code><a cbot|protected>protected</a></code>. Such members can only be accessed inside of the class definition."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:53
|
||||
#, no-wrap
|
||||
msgid "Fields and methods can also be declared as <code><a cbot|static>static</a></code>. Methods can be additionaly declared as <code><a cbot|synchro>synchronized</a></code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:56
|
||||
#, no-wrap
|
||||
msgid "As shown in the previous exemple, the class members can be initialized in the class definition (<c/>int x = 3.33;<n/>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:58
|
||||
#, no-wrap
|
||||
msgid "Another way of initiliazing fields is by defining a constructor which is a special method having the same name as the class. This method will be called automatically at <a cbot|new>creation</a> time of a class instance. Constructors can be <a cbot|function>overloaded</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:31
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint myField = 0;\n"
|
||||
"\tint MyFunction()\n"
|
||||
"\t{\n"
|
||||
"\t\treturn myField * 2;\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass myObject();\n"
|
||||
"\tmyObject.myField = 10;\n"
|
||||
"\tmessage(myObject.MyFunction()); // 20\n"
|
||||
"\tMyClass mySecondObject();\n"
|
||||
"\tmySecondObject.myField = myObject.myField - 2;\n"
|
||||
"\tmessage(mySecondObject.MyFunction()); // 16\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:121
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|protected>protected</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>, <code><a cbot|super>super</a></code>, <code><a cbot|extends>extends</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
|
|
@ -52,7 +52,7 @@ msgid "Time in seconds."
|
|||
msgstr "Temps en secondes."
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:120 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "Voir aussi"
|
||||
|
@ -581,12 +581,6 @@ msgstr "<a cbot>Programmation</a> et <a cbot|type>types</a>."
|
|||
msgid "Instruction <code>class</code>"
|
||||
msgstr "Instruction <code>class</code> (pour spécialistes)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This allows you to declare a class definition using following syntax:"
|
||||
msgstr "La syntaxe pour déclarer une classe est la suivante:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:4
|
||||
#, no-wrap
|
||||
|
@ -601,162 +595,6 @@ msgstr ""
|
|||
"\tdéclarations;\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "Classes can only be <a cbot|public>public</a>, that is they can be used from all bots in a mission. Class members are also public, that is they are accessible from outside the class. Class members can be fields or functions (also called methods), for example the followin class <code>MyClass</code> contains 4 fields (a, b, x and s) and one method (MyFunction)."
|
||||
msgstr "La classe est d'office <a cbot|public>publique</a> (disponible partout). Les membres de la classe sont également publiques (disponible à tous). Les déclarations peuvent être des déclarations de champs ou des déclarations de méthodes (avec le <a cbot|bloc>bloc</a> d'exécution). Une classe peut contenir des <a cbot|var>variables</a> et des <a cbot|function>fonctions</a>. Mais dans la terminologie des langages orientés objets, on les appelle \"champs\" et \"méthodes\". Le terme \"membre\" désigne un champ ou une méthode."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:11
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MaClasse\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MaPrimitive( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:22
|
||||
#, no-wrap
|
||||
msgid "As shown in this exemple the class members can be initialized (<code>x=3.33</code>). You can also define a constructor which is a special method having the same name as the class name. This method will be called automatically at creation time of a class instance. You can also declare more than one method with the same name but different parameters."
|
||||
msgstr ""
|
||||
"Comme le montre cet exemple, il est possible d'initialiser la valeur des champs par défaut (<code>x=3.33</code>), ce qui rend le constructeur inutile. Toutefois, il est possible de définir un constructeur, en créant une méthode (de type <code>void</code>) ayant le même nom que la classe.\n"
|
||||
"Il est également possible de définir plusieurs méthodes ayant le même nom, mais avec des paramètres différents (ce qui est aussi valable pour les <a cbot|function>fonctions</a>)."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:24
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MaClasse\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MaClasse( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MaClasse( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:37
|
||||
#, no-wrap
|
||||
msgid "In this example two constructors are declared for <code>MyClass</code>, one without parameters and the other one with two parameters. As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> et <code>b</code> we must use the <code><a cbot|this>this</a>.a</code> and <code><a cbot|this>this</a>.b</code> to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters."
|
||||
msgstr ""
|
||||
"Cet exemple déclare deux constructeurs pour <code>MaClasse</code>, l'un sans paramètre, l'autre avec deux paramètres. Comme les paramètres ont été nommés avec le même nom que les éléments <code>a</code> et <code>b</code>, il est nécessaire d'utiliser <code><a cbot|this>this</a>.a</code> et <code><a cbot|this>this</a>.b</code> pour accéder aux éléments de l'instance (une solution plus simple consiste à donner des noms différents pour les paramètres).\n"
|
||||
"Les constructeurs sont appelés automatiquement à la définition d'une instance de la classe."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:39
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMyClass item1(); // constr. w/o parameters\n"
|
||||
"\tMyClass item2(4, 5); // constr. with 2 parameters\n"
|
||||
"\tMyClass item3; // no constructor called,\n"
|
||||
" // therefore item3 == null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMaClasse item1(); // constr. sans paramètre\n"
|
||||
"\tMaClasse item2(4, 5); // constr. avec 2 paramètres\n"
|
||||
"\tMaClasse item3; // pas de constructeur,\n"
|
||||
" // item3 == null\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:47
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code>void</code> fonction without parameters that has the same name as the class name but prefixed by the ~ character. The destructor is called automatically as soon as the class instance is no more referenced by anyone."
|
||||
msgstr "Un destructeur peut être également défini. C'est une méthode <code>void</code> sans paramètre ayant le nom de la classe précédé du caractère \"tilde\" ~. Le destructeur est appelé dès qu'il n'y a plus aucune <a cbot|pointer>référence</a> vers une instance donnée."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:49
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass item1( ); // counter = 1\n"
|
||||
"\tMyClass item2( ); // counter = 2\n"
|
||||
"\titem1 = null; // counter = 1\n"
|
||||
"} // counter = 0"
|
||||
msgstr ""
|
||||
"public class MaClasse\n"
|
||||
"{\n"
|
||||
"\tstatic private int compteur = 0;\n"
|
||||
"\tvoid MaClasse( ) { compteur ++ ); // compte\n"
|
||||
"\tvoid ~MaClasse( ) { compteur -- }; // décompte\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMaClasse item1( ); // compteur = 1\n"
|
||||
"\tMaClasse item2( ); // compteur = 2\n"
|
||||
"\titem1 = null; // compteur = 1\n"
|
||||
"} // compteur = 0"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:68
|
||||
#, no-wrap
|
||||
msgid "If you pass a class instance as parameter to a <a cbot|function>function</a>, the function only receives a <a cbot|pointer>reference</a> to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified."
|
||||
msgstr "Lorsqu'on donne l'instance d'une classe comme paramètre d'une <a cbot|function>fonction</a>, c'est toujours la <a cbot|pointer>référence</a> qui est passée."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:71
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>pointer</a></code>\n"
|
||||
"<a cbot>Programmation</a>, <a cbot|type>types</a> et <a cbot|category>catégories</a>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/close.txt:1
|
||||
#, no-wrap
|
||||
|
@ -8303,3 +8141,258 @@ msgid ""
|
|||
" <code><a object|target1>Target1</a> </code>Flying target\n"
|
||||
" <code><a object|nest>AlienNest</a> </code>Alien Nest"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:10
|
||||
#, no-wrap
|
||||
msgid "Classes can be only <a cbot|public>public</a>. This means that they can be used by all bots in a mission."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:12
|
||||
#, no-wrap
|
||||
msgid "Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:13
|
||||
#, no-wrap
|
||||
msgid "Class members are fields (<a cbot|var>variables</a>) and methods (<a cbot|function>functions</a>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:15
|
||||
#, no-wrap
|
||||
msgid "For example, the following class dubbed <code>MyClass</code> contains 4 fields (<code>a</code>, <code>b</code>, <code>x</code> and <code>s</code>) and one method (<code>MyFunction</code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:17
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction(float value)\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value * x) - 1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:55
|
||||
#, no-wrap
|
||||
msgid "Member Initialization"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:60
|
||||
#, no-wrap
|
||||
msgid "Example:<c/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:61
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass()\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass(int a, int b)\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:76
|
||||
#, no-wrap
|
||||
msgid "As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> and <code>b</code>, we must use the <code><a cbot|this>this</a></code> <a cbot|pointer>reference</a> to avoid confusion with the parameters' names."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:78
|
||||
#, no-wrap
|
||||
msgid "Object Creation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:79
|
||||
#, no-wrap
|
||||
msgid "You can create objects of type <code>YourClass</code> using the <code><a cbot|new>new</a></code> keyword. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:90
|
||||
#, no-wrap
|
||||
msgid "Object Destruction"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:114
|
||||
#, no-wrap
|
||||
msgid "Passing Objects to Functions"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:115
|
||||
#, no-wrap
|
||||
msgid "Objects in CBOT are passed by <a cbot|pointer>reference</a>. This means that when an object is passed to a <a cbot|function>function</a>, the function receives a copy of a pointer to the instance, not a copy of the object, so any modifications on the object will be visible outside of the function."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:117
|
||||
#, no-wrap
|
||||
msgid "Inheritance"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:118
|
||||
#, no-wrap
|
||||
msgid "A class can inherit public and protected members of another class by using the <code><a cbot|extends>extends</a></code> keyword."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This keyword allows you to create a class definition by using the following syntax:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "All Classes Are Public"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:52
|
||||
#, no-wrap
|
||||
msgid "Class Members Modifiers"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:75
|
||||
#, no-wrap
|
||||
msgid "Using <code><a cbot|this>this</a></code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:81
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass object1(); // Call default constructor (without parameters)\n"
|
||||
"\tMyClass object2(4, 5); // Call constructor with two int parameters\n"
|
||||
"\tMyClass object3; // No constructor called, object3 == null\n"
|
||||
"\tobject3 = new MyClass(); // We call constructor now, object3 != null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:91
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code><a cbot|void>void</a></code> fonction without parameters, which has the same name as the class but prefixed with the <code>~</code> character. The destructor is called automatically as soon as the class instance is no more referenced by anyone. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:93
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter--; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\t // counter == 0\n"
|
||||
"\tMyClass item1( ); // counter == 1\n"
|
||||
"\tMyClass item2( ); // counter == 2\n"
|
||||
"\titem1 = null; // counter == 1\n"
|
||||
"}\n"
|
||||
"// counter == 0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:28
|
||||
#, no-wrap
|
||||
msgid "Accessing Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:29
|
||||
#, no-wrap
|
||||
msgid "Class members can be accessed outside of the class definition by using the <code>.</code> operator. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:50
|
||||
#, no-wrap
|
||||
msgid "Class members are <a cbot|public>public</a> by default, which means that they are accessible outside of the class definition. They can also be declared as <code><a cbot|private>private</a></code> or <code><a cbot|protected>protected</a></code>. Such members can only be accessed inside of the class definition."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:53
|
||||
#, no-wrap
|
||||
msgid "Fields and methods can also be declared as <code><a cbot|static>static</a></code>. Methods can be additionaly declared as <code><a cbot|synchro>synchronized</a></code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:56
|
||||
#, no-wrap
|
||||
msgid "As shown in the previous exemple, the class members can be initialized in the class definition (<c/>int x = 3.33;<n/>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:58
|
||||
#, no-wrap
|
||||
msgid "Another way of initiliazing fields is by defining a constructor which is a special method having the same name as the class. This method will be called automatically at <a cbot|new>creation</a> time of a class instance. Constructors can be <a cbot|function>overloaded</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:31
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint myField = 0;\n"
|
||||
"\tint MyFunction()\n"
|
||||
"\t{\n"
|
||||
"\t\treturn myField * 2;\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass myObject();\n"
|
||||
"\tmyObject.myField = 10;\n"
|
||||
"\tmessage(myObject.MyFunction()); // 20\n"
|
||||
"\tMyClass mySecondObject();\n"
|
||||
"\tmySecondObject.myField = myObject.myField - 2;\n"
|
||||
"\tmessage(mySecondObject.MyFunction()); // 16\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:121
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|protected>protected</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>, <code><a cbot|super>super</a></code>, <code><a cbot|extends>extends</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
|
|
@ -53,7 +53,7 @@ msgid "Time in seconds."
|
|||
msgstr "Czas w sekundach."
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:120 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "Zobacz również"
|
||||
|
@ -580,12 +580,6 @@ msgstr "<a cbot>Język CBOT</a> i <a cbot|type>zmienne</a>."
|
|||
msgid "Instruction <code>class</code>"
|
||||
msgstr "Instrukcja <code>class</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This allows you to declare a class definition using following syntax:"
|
||||
msgstr "Pozwala na zadeklarowanie definicji klasy, przy użyciu następującej składni:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:4
|
||||
#, no-wrap
|
||||
|
@ -600,164 +594,6 @@ msgstr ""
|
|||
"\tdeklaracje;\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "Classes can only be <a cbot|public>public</a>, that is they can be used from all bots in a mission. Class members are also public, that is they are accessible from outside the class. Class members can be fields or functions (also called methods), for example the followin class <code>MyClass</code> contains 4 fields (a, b, x and s) and one method (MyFunction)."
|
||||
msgstr "Klasy mogą być tylko typu <a cbot|public>public</a> (publiczne), a więc mogą być używane podczas misji przez wszystkie roboty. Elementy klasy również są publiczne, dostępne spoza klasy. Do klasy mogą należeć pola lub funkcje (zwane również metodami), na przykład następująca klasa <code>MojaKlasa</code> zawiera 4 pola (a, b, x oraz s) i jedną metodę (MojaFunkcja)."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:11
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MojaKlasa\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"Cześć\";\n"
|
||||
"\tfloat MojaFunkcja( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:22
|
||||
#, no-wrap
|
||||
msgid "As shown in this exemple the class members can be initialized (<code>x=3.33</code>). You can also define a constructor which is a special method having the same name as the class name. This method will be called automatically at creation time of a class instance. You can also declare more than one method with the same name but different parameters."
|
||||
msgstr "Jak pokazano na tym przykładzie, elementy klasy mogą być inicjalizowane (<code>x=3.33</code>). Można też zdefiniować konstruktor, który jest specjalną metodą o nazwie takiej samej jak nazwa klasy. Metoda ta jest wywoływana automatycznie podczas tworzenia instancji klasy. Możliwe jest również zadeklarowanie więcej niż jednej metody o tej samej nazwie ale o innych parametrach."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:24
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MojaKlasa\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MojaKlasa( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MojaKlasa( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:37
|
||||
#, no-wrap
|
||||
msgid "In this example two constructors are declared for <code>MyClass</code>, one without parameters and the other one with two parameters. As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> et <code>b</code> we must use the <code><a cbot|this>this</a>.a</code> and <code><a cbot|this>this</a>.b</code> to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters."
|
||||
msgstr "W tym przykładzie zadeklarowano dwa konstruktory dla klasy <code>MojaKlasa</code>, jeden bez parametrów, drugi z dwoma parametrami. Jako że nazwy parametrów drugiego konstruktora są takie same jak nazwy dwóch pól klasy <code>a</code> et <code>b</code> konieczne jest użycie <code><a cbot|this>this</a>.a</code> i <code><a cbot|this>this</a>.b</code> w celu rozróżnienia parametrów. Inne, prostsze rozwiązanie, to nadanie różnych nazw parametrom."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:39
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMyClass item1(); // constr. w/o parameters\n"
|
||||
"\tMyClass item2(4, 5); // constr. with 2 parameters\n"
|
||||
"\tMyClass item3; // no constructor called,\n"
|
||||
" // therefore item3 == null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMojaKlasa element1(); // konstruktor bez parametrów\n"
|
||||
"\tMojaKlasa element2(4, 5); // konstruktor z 2 parametrami\n"
|
||||
"\tMojaKlasa element3; // konstruktor nie jest wywoływany,\n"
|
||||
" // więc item3 == null\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:47
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code>void</code> fonction without parameters that has the same name as the class name but prefixed by the ~ character. The destructor is called automatically as soon as the class instance is no more referenced by anyone."
|
||||
msgstr "Można też zdefinować destruktor. Musi to być funkcja <code>void</code> bez parametrów o takiej samej nazwie jak nazwa klasy, poprzedzona znakiem ~. Destruktor jest wywoływany automatycznie gdy nie ma już żadnych odwołań do instancji klasy."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:49
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass item1( ); // counter = 1\n"
|
||||
"\tMyClass item2( ); // counter = 2\n"
|
||||
"\titem1 = null; // counter = 1\n"
|
||||
"} // counter = 0"
|
||||
msgstr ""
|
||||
"public class MojaKlasa\n"
|
||||
"{\n"
|
||||
"\tstatic private int licznik = 0; // licznik instancji\n"
|
||||
"\tvoid MojaKlasa( )\n"
|
||||
"\t{\n"
|
||||
"\t\tlicznik ++; // jedna instancja więcej\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MojaKlasa( )\n"
|
||||
"\t{\n"
|
||||
"\t\tlicznik --; // jedna instancja mniej\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMojaKlasa element1( ); // licznik = 1\n"
|
||||
"\tMojaKlasa element2( ); // licznik = 2\n"
|
||||
"\telement1 = null; // licznik = 1\n"
|
||||
"} // licznik = 0"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:68
|
||||
#, no-wrap
|
||||
msgid "If you pass a class instance as parameter to a <a cbot|function>function</a>, the function only receives a <a cbot|pointer>reference</a> to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified."
|
||||
msgstr "W przypadku przekazywania instancji klasy jako parametru <a cbot|function>funkcji</a>, otrzymuje ona tylko <a cbot|pointer>wskaźnik</a> do instancji. Oznacza to, że jeśli zostanie zmodyfikowana instancja wewnątrz funkcji, w rzeczywistości zostanie zmodyfikowana instancja przekazana funkcji."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:71
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>wskaźnik</a></code>, <code><a cbot|this>this</a></code>\n"
|
||||
"<a cbot>Programowanie</a>, <a cbot|type>typy</a> i <a cbot|category>kategorie</a>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/close.txt:1
|
||||
#, no-wrap
|
||||
|
@ -8472,3 +8308,258 @@ msgid ""
|
|||
" <code><a object|target1>Target1</a> </code>Flying target\n"
|
||||
" <code><a object|nest>AlienNest</a> </code>Alien Nest"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:10
|
||||
#, no-wrap
|
||||
msgid "Classes can be only <a cbot|public>public</a>. This means that they can be used by all bots in a mission."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:12
|
||||
#, no-wrap
|
||||
msgid "Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:13
|
||||
#, no-wrap
|
||||
msgid "Class members are fields (<a cbot|var>variables</a>) and methods (<a cbot|function>functions</a>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:15
|
||||
#, no-wrap
|
||||
msgid "For example, the following class dubbed <code>MyClass</code> contains 4 fields (<code>a</code>, <code>b</code>, <code>x</code> and <code>s</code>) and one method (<code>MyFunction</code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:17
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction(float value)\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value * x) - 1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:55
|
||||
#, no-wrap
|
||||
msgid "Member Initialization"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:60
|
||||
#, no-wrap
|
||||
msgid "Example:<c/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:61
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass()\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass(int a, int b)\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:76
|
||||
#, no-wrap
|
||||
msgid "As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> and <code>b</code>, we must use the <code><a cbot|this>this</a></code> <a cbot|pointer>reference</a> to avoid confusion with the parameters' names."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:78
|
||||
#, no-wrap
|
||||
msgid "Object Creation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:79
|
||||
#, no-wrap
|
||||
msgid "You can create objects of type <code>YourClass</code> using the <code><a cbot|new>new</a></code> keyword. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:90
|
||||
#, no-wrap
|
||||
msgid "Object Destruction"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:114
|
||||
#, no-wrap
|
||||
msgid "Passing Objects to Functions"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:115
|
||||
#, no-wrap
|
||||
msgid "Objects in CBOT are passed by <a cbot|pointer>reference</a>. This means that when an object is passed to a <a cbot|function>function</a>, the function receives a copy of a pointer to the instance, not a copy of the object, so any modifications on the object will be visible outside of the function."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:117
|
||||
#, no-wrap
|
||||
msgid "Inheritance"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:118
|
||||
#, no-wrap
|
||||
msgid "A class can inherit public and protected members of another class by using the <code><a cbot|extends>extends</a></code> keyword."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This keyword allows you to create a class definition by using the following syntax:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "All Classes Are Public"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:52
|
||||
#, no-wrap
|
||||
msgid "Class Members Modifiers"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:75
|
||||
#, no-wrap
|
||||
msgid "Using <code><a cbot|this>this</a></code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:81
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass object1(); // Call default constructor (without parameters)\n"
|
||||
"\tMyClass object2(4, 5); // Call constructor with two int parameters\n"
|
||||
"\tMyClass object3; // No constructor called, object3 == null\n"
|
||||
"\tobject3 = new MyClass(); // We call constructor now, object3 != null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:91
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code><a cbot|void>void</a></code> fonction without parameters, which has the same name as the class but prefixed with the <code>~</code> character. The destructor is called automatically as soon as the class instance is no more referenced by anyone. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:93
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter--; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\t // counter == 0\n"
|
||||
"\tMyClass item1( ); // counter == 1\n"
|
||||
"\tMyClass item2( ); // counter == 2\n"
|
||||
"\titem1 = null; // counter == 1\n"
|
||||
"}\n"
|
||||
"// counter == 0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:28
|
||||
#, no-wrap
|
||||
msgid "Accessing Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:29
|
||||
#, no-wrap
|
||||
msgid "Class members can be accessed outside of the class definition by using the <code>.</code> operator. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:50
|
||||
#, no-wrap
|
||||
msgid "Class members are <a cbot|public>public</a> by default, which means that they are accessible outside of the class definition. They can also be declared as <code><a cbot|private>private</a></code> or <code><a cbot|protected>protected</a></code>. Such members can only be accessed inside of the class definition."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:53
|
||||
#, no-wrap
|
||||
msgid "Fields and methods can also be declared as <code><a cbot|static>static</a></code>. Methods can be additionaly declared as <code><a cbot|synchro>synchronized</a></code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:56
|
||||
#, no-wrap
|
||||
msgid "As shown in the previous exemple, the class members can be initialized in the class definition (<c/>int x = 3.33;<n/>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:58
|
||||
#, no-wrap
|
||||
msgid "Another way of initiliazing fields is by defining a constructor which is a special method having the same name as the class. This method will be called automatically at <a cbot|new>creation</a> time of a class instance. Constructors can be <a cbot|function>overloaded</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:31
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint myField = 0;\n"
|
||||
"\tint MyFunction()\n"
|
||||
"\t{\n"
|
||||
"\t\treturn myField * 2;\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass myObject();\n"
|
||||
"\tmyObject.myField = 10;\n"
|
||||
"\tmessage(myObject.MyFunction()); // 20\n"
|
||||
"\tMyClass mySecondObject();\n"
|
||||
"\tmySecondObject.myField = myObject.myField - 2;\n"
|
||||
"\tmessage(mySecondObject.MyFunction()); // 16\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:121
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|protected>protected</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>, <code><a cbot|super>super</a></code>, <code><a cbot|extends>extends</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
|
|
@ -53,7 +53,7 @@ msgid "Time in seconds."
|
|||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:41 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:109 ../E/ceil.txt:12 ../E/class.txt:120 ../E/close.txt:6 ../E/cond.txt:4 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:197 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:51 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/radarall.txt:19 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "См. также"
|
||||
|
@ -579,12 +579,6 @@ msgstr "<a cbot>Язык CBOT</a> и <a cbot|type>Переменные</a>."
|
|||
msgid "Instruction <code>class</code>"
|
||||
msgstr "Инструкция <code>class</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This allows you to declare a class definition using following syntax:"
|
||||
msgstr "Синтаксис:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:4
|
||||
#, no-wrap
|
||||
|
@ -599,164 +593,6 @@ msgstr ""
|
|||
"\tdeclarations;\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "Classes can only be <a cbot|public>public</a>, that is they can be used from all bots in a mission. Class members are also public, that is they are accessible from outside the class. Class members can be fields or functions (also called methods), for example the followin class <code>MyClass</code> contains 4 fields (a, b, x and s) and one method (MyFunction)."
|
||||
msgstr "Классы должны быть <a cbot|public>общедоступными</a>, таким образом они могут быть исползованы всеми ботами в любой миссии. Члены класса также должны быть общедоступными, тоесть должны быть доступны за пределами класса. Членами класса могут быть ячейки и функции (по-другому методы), например следующий класс <code>MyClass</code> содержит 4 ячейки (a, b, x и s) и один метод (MyFunction)."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:11
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction( float value )\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value*x)-1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:22
|
||||
#, no-wrap
|
||||
msgid "As shown in this exemple the class members can be initialized (<code>x=3.33</code>). You can also define a constructor which is a special method having the same name as the class name. This method will be called automatically at creation time of a class instance. You can also declare more than one method with the same name but different parameters."
|
||||
msgstr "ак показано в данном примере члены класса могут быть инициализированы (<code>x=3.33</code>). Вы можете также определить конструктор, который представляет собой специальный метод, имеющий то же имя, как и имя класса. Этот метод будет вызван автоматически в момент создания экземпляра класса. Вы можете также объявить более одного метода с тем же именем, но с разными параметрами."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:24
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass( int a, int b )\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:37
|
||||
#, no-wrap
|
||||
msgid "In this example two constructors are declared for <code>MyClass</code>, one without parameters and the other one with two parameters. As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> et <code>b</code> we must use the <code><a cbot|this>this</a>.a</code> and <code><a cbot|this>this</a>.b</code> to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters."
|
||||
msgstr "В этом примере два конструктора были объявлены как <code>MyClass</code>, один без параметров и второй с двумя параметрами. Поскольку имена параметров второго конструктора такие же, как и имена двух членов <code>a</code> и <code>b</code> мы должны использовать <code><a cbot|this>this</a>.a</code> и <code><a cbot|this>this</a>.b</code> чтобы избежать путаницы с параметрами. Наболее простым решением было бы дать разные имена параметрам."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:39
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMyClass item1(); // constr. w/o parameters\n"
|
||||
"\tMyClass item2(4, 5); // constr. with 2 parameters\n"
|
||||
"\tMyClass item3; // no constructor called,\n"
|
||||
" // therefore item3 == null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
"void Test( )\n"
|
||||
"{\n"
|
||||
"\tMyClass item1(); // конструктор без параметров\n"
|
||||
"\tMyClass item2(4, 5); // конструктор с двумя параметрами\n"
|
||||
"\tMyClass item3; // нет вызова конструктора,\n"
|
||||
" // поэтому item3 == null\n"
|
||||
"}"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:47
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code>void</code> fonction without parameters that has the same name as the class name but prefixed by the ~ character. The destructor is called automatically as soon as the class instance is no more referenced by anyone."
|
||||
msgstr "Вы также можете определить деструктор. Это должна быть <code>пустая(void)</code> функция без параметров, имеющая то же имя, что и класс, но с первиксом ~. Деструктор вызывается автоматически, как только класс уже больше никому не понадобится."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:49
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass item1( ); // counter = 1\n"
|
||||
"\tMyClass item2( ); // counter = 2\n"
|
||||
"\titem1 = null; // counter = 1\n"
|
||||
"} // counter = 0"
|
||||
msgstr ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // инициализируем счетчик\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter ++; // увеличиваем\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter --; // уменьшаем\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"void Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass item1( ); // счетчик = 1\n"
|
||||
"\tMyClass item2( ); // счетчик = 2\n"
|
||||
"\titem1 = null; // счетчик = 1\n"
|
||||
"} // счетчик = 0"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:68
|
||||
#, no-wrap
|
||||
msgid "If you pass a class instance as parameter to a <a cbot|function>function</a>, the function only receives a <a cbot|pointer>reference</a> to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified."
|
||||
msgstr "If you pass a class instance as parameter to a <a cbot|function>function</a>, the function only receives a <a cbot|pointer>reference</a> to the instance. That means if you modify the instance in the function, the instance that has been passed to the function will be actuallay modified."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:71
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
"<code><a cbot|public>Общедоступное</a></code>, <code><a cbot|private>приватное</a></code>, <code><a cbot|static>статичное</a></code>, <code><a cbot|synchro>синхронизированное</a></code>, <code><a cbot|new>новое</a></code>, <code><a cbot|pointer>ссылка</a></code>, <code><a cbot|this>это</a></code>\n"
|
||||
"<a cbot>Язык CBOT</a> и <a cbot|type>Переменные</a> и <a cbot|category>категории</a>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/close.txt:1
|
||||
#, no-wrap
|
||||
|
@ -8285,3 +8121,258 @@ msgid ""
|
|||
" <code><a object|target1>Target1</a> </code>Flying target\n"
|
||||
" <code><a object|nest>AlienNest</a> </code>Alien Nest"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:10
|
||||
#, no-wrap
|
||||
msgid "Classes can be only <a cbot|public>public</a>. This means that they can be used by all bots in a mission."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:12
|
||||
#, no-wrap
|
||||
msgid "Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:13
|
||||
#, no-wrap
|
||||
msgid "Class members are fields (<a cbot|var>variables</a>) and methods (<a cbot|function>functions</a>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:15
|
||||
#, no-wrap
|
||||
msgid "For example, the following class dubbed <code>MyClass</code> contains 4 fields (<code>a</code>, <code>b</code>, <code>x</code> and <code>s</code>) and one method (<code>MyFunction</code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:17
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tfloat x = 3.33;\n"
|
||||
"\tstring s = \"hello\";\n"
|
||||
"\tfloat MyFunction(float value)\n"
|
||||
"\t{\n"
|
||||
"\t\treturn (value * x) - 1;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:55
|
||||
#, no-wrap
|
||||
msgid "Member Initialization"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:60
|
||||
#, no-wrap
|
||||
msgid "Example:<c/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:61
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint a, b;\n"
|
||||
"\tvoid MyClass()\n"
|
||||
"\t{\n"
|
||||
"\t\ta = 2; b = 3;\n"
|
||||
"\t}\n"
|
||||
"\tvoid MyClass(int a, int b)\n"
|
||||
"\t{\n"
|
||||
"\t\tthis.a = a; this.b = b;\n"
|
||||
"\t}\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:76
|
||||
#, no-wrap
|
||||
msgid "As the names of the parameters of the second constructor are the same as the names of the two members <code>a</code> and <code>b</code>, we must use the <code><a cbot|this>this</a></code> <a cbot|pointer>reference</a> to avoid confusion with the parameters' names."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:78
|
||||
#, no-wrap
|
||||
msgid "Object Creation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:79
|
||||
#, no-wrap
|
||||
msgid "You can create objects of type <code>YourClass</code> using the <code><a cbot|new>new</a></code> keyword. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:90
|
||||
#, no-wrap
|
||||
msgid "Object Destruction"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:114
|
||||
#, no-wrap
|
||||
msgid "Passing Objects to Functions"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:115
|
||||
#, no-wrap
|
||||
msgid "Objects in CBOT are passed by <a cbot|pointer>reference</a>. This means that when an object is passed to a <a cbot|function>function</a>, the function receives a copy of a pointer to the instance, not a copy of the object, so any modifications on the object will be visible outside of the function."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:117
|
||||
#, no-wrap
|
||||
msgid "Inheritance"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:118
|
||||
#, no-wrap
|
||||
msgid "A class can inherit public and protected members of another class by using the <code><a cbot|extends>extends</a></code> keyword."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:2
|
||||
#, no-wrap
|
||||
msgid "This keyword allows you to create a class definition by using the following syntax:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:9
|
||||
#, no-wrap
|
||||
msgid "All Classes Are Public"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:52
|
||||
#, no-wrap
|
||||
msgid "Class Members Modifiers"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/class.txt:75
|
||||
#, no-wrap
|
||||
msgid "Using <code><a cbot|this>this</a></code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:81
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass object1(); // Call default constructor (without parameters)\n"
|
||||
"\tMyClass object2(4, 5); // Call constructor with two int parameters\n"
|
||||
"\tMyClass object3; // No constructor called, object3 == null\n"
|
||||
"\tobject3 = new MyClass(); // We call constructor now, object3 != null\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:91
|
||||
#, no-wrap
|
||||
msgid "You can also define a destructor. This must be a <code><a cbot|void>void</a></code> fonction without parameters, which has the same name as the class but prefixed with the <code>~</code> character. The destructor is called automatically as soon as the class instance is no more referenced by anyone. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:93
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tstatic private int counter = 0; // instance counter\n"
|
||||
"\tvoid MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter++; // one instance more\n"
|
||||
"\t}\n"
|
||||
"\tvoid ~MyClass( )\n"
|
||||
"\t{\n"
|
||||
"\t\tcounter--; // one instance less\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\t // counter == 0\n"
|
||||
"\tMyClass item1( ); // counter == 1\n"
|
||||
"\tMyClass item2( ); // counter == 2\n"
|
||||
"\titem1 = null; // counter == 1\n"
|
||||
"}\n"
|
||||
"// counter == 0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/class.txt:28
|
||||
#, no-wrap
|
||||
msgid "Accessing Class Members"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:29
|
||||
#, no-wrap
|
||||
msgid "Class members can be accessed outside of the class definition by using the <code>.</code> operator. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:50
|
||||
#, no-wrap
|
||||
msgid "Class members are <a cbot|public>public</a> by default, which means that they are accessible outside of the class definition. They can also be declared as <code><a cbot|private>private</a></code> or <code><a cbot|protected>protected</a></code>. Such members can only be accessed inside of the class definition."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:53
|
||||
#, no-wrap
|
||||
msgid "Fields and methods can also be declared as <code><a cbot|static>static</a></code>. Methods can be additionaly declared as <code><a cbot|synchro>synchronized</a></code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:56
|
||||
#, no-wrap
|
||||
msgid "As shown in the previous exemple, the class members can be initialized in the class definition (<c/>int x = 3.33;<n/>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:58
|
||||
#, no-wrap
|
||||
msgid "Another way of initiliazing fields is by defining a constructor which is a special method having the same name as the class. This method will be called automatically at <a cbot|new>creation</a> time of a class instance. Constructors can be <a cbot|function>overloaded</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/class.txt:31
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"public class MyClass\n"
|
||||
"{\n"
|
||||
"\tint myField = 0;\n"
|
||||
"\tint MyFunction()\n"
|
||||
"\t{\n"
|
||||
"\t\treturn myField * 2;\n"
|
||||
"\t}\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"extern void object::Test()\n"
|
||||
"{\n"
|
||||
"\tMyClass myObject();\n"
|
||||
"\tmyObject.myField = 10;\n"
|
||||
"\tmessage(myObject.MyFunction()); // 20\n"
|
||||
"\tMyClass mySecondObject();\n"
|
||||
"\tmySecondObject.myField = myObject.myField - 2;\n"
|
||||
"\tmessage(mySecondObject.MyFunction()); // 16\n"
|
||||
"}"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/class.txt:121
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code><a cbot|public>public</a></code>, <code><a cbot|private>private</a></code>, <code><a cbot|protected>protected</a></code>, <code><a cbot|static>static</a></code>, <code><a cbot|synchro>synchronized</a></code>, <code><a cbot|new>new</a></code>, <code><a cbot|pointer>reference</a></code>, <code><a cbot|this>this</a></code>, <code><a cbot|super>super</a></code>, <code><a cbot|extends>extends</a></code>\n"
|
||||
"<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
|
Loading…
Reference in New Issue