From ea32d482c5f78e4ac92fa07cad6685a9f21645ce Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 10 Sep 2016 15:43:23 +0200 Subject: [PATCH] [SATCOM] Rewrite "class" --- help/cbot/E/class.txt | 96 ++++++--- help/cbot/E/extends.txt | 0 help/cbot/E/protected.txt | 0 help/cbot/E/super.txt | 0 help/cbot/po/cbot.pot | 372 ++++++++++++++++++++++----------- help/cbot/po/de.po | 421 +++++++++++++++++++++++--------------- help/cbot/po/fr.po | 419 ++++++++++++++++++++++--------------- help/cbot/po/pl.po | 421 +++++++++++++++++++++++--------------- help/cbot/po/ru.po | 421 +++++++++++++++++++++++--------------- 9 files changed, 1353 insertions(+), 797 deletions(-) create mode 100644 help/cbot/E/extends.txt create mode 100644 help/cbot/E/protected.txt create mode 100644 help/cbot/E/super.txt diff --git a/help/cbot/E/class.txt b/help/cbot/E/class.txt index 942d7b0e..c3ecd83b 100644 --- a/help/cbot/E/class.txt +++ b/help/cbot/E/class.txt @@ -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;. diff --git a/help/cbot/E/extends.txt b/help/cbot/E/extends.txt new file mode 100644 index 00000000..e69de29b diff --git a/help/cbot/E/protected.txt b/help/cbot/E/protected.txt new file mode 100644 index 00000000..e69de29b diff --git a/help/cbot/E/super.txt b/help/cbot/E/super.txt new file mode 100644 index 00000000..e69de29b diff --git a/help/cbot/po/cbot.pot b/help/cbot/po/cbot.pot index 51043e4f..ebd1fb89 100644 --- a/help/cbot/po/cbot.pot +++ b/help/cbot/po/cbot.pot @@ -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 class" 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 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 MyClass 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 (x=3.33). 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 MyClass, 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 a et b we must use the this.a and this.b 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 void 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 function, the function only receives a reference 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 "" -"public, private, static, synchronized, new, reference, this\n" -"Programming, types and categories." -msgstr "" - #. type: \b; header #: ../E/close.txt:1 #, no-wrap @@ -7548,3 +7433,258 @@ msgid "" " Target1 Flying target\n" " AlienNest Alien Nest" msgstr "" + +#. type: Plain text +#: ../E/class.txt:10 +#, no-wrap +msgid "Classes can be only public. 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 (variables) and methods (functions)." +msgstr "" + +#. type: Plain text +#: ../E/class.txt:15 +#, no-wrap +msgid "For example, the following class dubbed MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." +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:" +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 a and b, we must use the this reference 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 YourClass using the new 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 reference. This means that when an object is passed to a 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." +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 extends 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 this" +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 void fonction without parameters, which has the same name as the class but prefixed with the ~ 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 . operator. Example:" +msgstr "" + +#. type: Plain text +#: ../E/class.txt:50 +#, no-wrap +msgid "Class members are public by default, which means that they are accessible outside of the class definition. They can also be declared as private or protected. 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 static. Methods can be additionaly declared as synchronized." +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 (int x = 3.33;)." +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 creation time of a class instance. Constructors can be overloaded." +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 "" +"public, private, protected, static, synchronized, new, reference, this, super, extends\n" +"Programming, types and categories." +msgstr "" diff --git a/help/cbot/po/de.po b/help/cbot/po/de.po index 1a3e0530..c5c86b14 100644 --- a/help/cbot/po/de.po +++ b/help/cbot/po/de.po @@ -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 CBOT-Sprache und die Variablentypen." msgid "Instruction class" msgstr "Anweisung class" -#. 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 "" "\tDeklarationen;\n" "}" -#. type: Plain text -#: ../E/class.txt:9 -#, no-wrap -msgid "Classes can only be 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 MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." -msgstr "Klassen können nur public (ö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 MeineKlasse 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 (x=3.33). 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. x=3.33). 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 MyClass, 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 a et b we must use the this.a and this.b 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 MeineKlasse 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 a und b, muss für eine Referenz auf die Instanzvariablen this.a und this.b 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 void 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 void-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 function, the function only receives a reference 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 Funktion übergeben, erhält die Funktion nur einen Zeiger 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 "" -"public, private, static, synchronized, new, reference, this\n" -"Programming, types and categories." -msgstr "" -"public, private, static, synchronized, new, Zeiger und this.\n" -"Die CBOT-Sprache, Variablentypen und Kategorien." - #. type: \b; header #: ../E/close.txt:1 #, no-wrap @@ -8306,3 +8142,258 @@ msgid "" " Target1 Flying target\n" " AlienNest Alien Nest" msgstr "" + +#. type: Plain text +#: ../E/class.txt:10 +#, no-wrap +msgid "Classes can be only public. 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 (variables) and methods (functions)." +msgstr "" + +#. type: Plain text +#: ../E/class.txt:15 +#, no-wrap +msgid "For example, the following class dubbed MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." +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:" +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 a and b, we must use the this reference 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 YourClass using the new 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 reference. This means that when an object is passed to a 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." +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 extends 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 this" +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 void fonction without parameters, which has the same name as the class but prefixed with the ~ 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 . operator. Example:" +msgstr "" + +#. type: Plain text +#: ../E/class.txt:50 +#, no-wrap +msgid "Class members are public by default, which means that they are accessible outside of the class definition. They can also be declared as private or protected. 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 static. Methods can be additionaly declared as synchronized." +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 (int x = 3.33;)." +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 creation time of a class instance. Constructors can be overloaded." +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 "" +"public, private, protected, static, synchronized, new, reference, this, super, extends\n" +"Programming, types and categories." +msgstr "" diff --git a/help/cbot/po/fr.po b/help/cbot/po/fr.po index 58a5159a..c0f7990a 100644 --- a/help/cbot/po/fr.po +++ b/help/cbot/po/fr.po @@ -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 "Programmation et types." msgid "Instruction class" msgstr "Instruction class (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 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 MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." -msgstr "La classe est d'office publique (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 bloc d'exécution). Une classe peut contenir des variables et des fonctions. 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 (x=3.33). 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 (x=3.33), ce qui rend le constructeur inutile. Toutefois, il est possible de définir un constructeur, en créant une méthode (de type void) 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 fonctions)." - -#. 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 MyClass, 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 a et b we must use the this.a and this.b 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 MaClasse, 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 a et b, il est nécessaire d'utiliser this.a et this.b 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 void 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 void 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 référence 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 function, the function only receives a reference 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 fonction, c'est toujours la référence qui est passée." - -#. type: Plain text -#: ../E/class.txt:71 -#, no-wrap -msgid "" -"public, private, static, synchronized, new, reference, this\n" -"Programming, types and categories." -msgstr "" -"public, private, static, synchronized, new, pointer\n" -"Programmation, types et catégories." - #. type: \b; header #: ../E/close.txt:1 #, no-wrap @@ -8303,3 +8141,258 @@ msgid "" " Target1 Flying target\n" " AlienNest Alien Nest" msgstr "" + +#. type: Plain text +#: ../E/class.txt:10 +#, no-wrap +msgid "Classes can be only public. 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 (variables) and methods (functions)." +msgstr "" + +#. type: Plain text +#: ../E/class.txt:15 +#, no-wrap +msgid "For example, the following class dubbed MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." +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:" +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 a and b, we must use the this reference 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 YourClass using the new 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 reference. This means that when an object is passed to a 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." +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 extends 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 this" +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 void fonction without parameters, which has the same name as the class but prefixed with the ~ 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 . operator. Example:" +msgstr "" + +#. type: Plain text +#: ../E/class.txt:50 +#, no-wrap +msgid "Class members are public by default, which means that they are accessible outside of the class definition. They can also be declared as private or protected. 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 static. Methods can be additionaly declared as synchronized." +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 (int x = 3.33;)." +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 creation time of a class instance. Constructors can be overloaded." +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 "" +"public, private, protected, static, synchronized, new, reference, this, super, extends\n" +"Programming, types and categories." +msgstr "" diff --git a/help/cbot/po/pl.po b/help/cbot/po/pl.po index 5a8d1301..b19de07c 100644 --- a/help/cbot/po/pl.po +++ b/help/cbot/po/pl.po @@ -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 "Język CBOT i zmienne." msgid "Instruction class" msgstr "Instrukcja class" -#. 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 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 MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." -msgstr "Klasy mogą być tylko typu public (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 MojaKlasa 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 (x=3.33). 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 (x=3.33). 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 MyClass, 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 a et b we must use the this.a and this.b 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 MojaKlasa, 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 a et b konieczne jest użycie this.a i this.b 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 void 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 void 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 function, the function only receives a reference 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 funkcji, otrzymuje ona tylko wskaźnik 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 "" -"public, private, static, synchronized, new, reference, this\n" -"Programming, types and categories." -msgstr "" -"public, private, static, synchronized, new, wskaźnik, this\n" -"Programowanie, typy i kategorie." - #. type: \b; header #: ../E/close.txt:1 #, no-wrap @@ -8472,3 +8308,258 @@ msgid "" " Target1 Flying target\n" " AlienNest Alien Nest" msgstr "" + +#. type: Plain text +#: ../E/class.txt:10 +#, no-wrap +msgid "Classes can be only public. 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 (variables) and methods (functions)." +msgstr "" + +#. type: Plain text +#: ../E/class.txt:15 +#, no-wrap +msgid "For example, the following class dubbed MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." +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:" +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 a and b, we must use the this reference 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 YourClass using the new 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 reference. This means that when an object is passed to a 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." +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 extends 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 this" +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 void fonction without parameters, which has the same name as the class but prefixed with the ~ 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 . operator. Example:" +msgstr "" + +#. type: Plain text +#: ../E/class.txt:50 +#, no-wrap +msgid "Class members are public by default, which means that they are accessible outside of the class definition. They can also be declared as private or protected. 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 static. Methods can be additionaly declared as synchronized." +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 (int x = 3.33;)." +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 creation time of a class instance. Constructors can be overloaded." +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 "" +"public, private, protected, static, synchronized, new, reference, this, super, extends\n" +"Programming, types and categories." +msgstr "" diff --git a/help/cbot/po/ru.po b/help/cbot/po/ru.po index 2c97e50a..9fa387c6 100644 --- a/help/cbot/po/ru.po +++ b/help/cbot/po/ru.po @@ -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 "Язык CBOT и Переменные." msgid "Instruction class" msgstr "Инструкция class" -#. 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 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 MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." -msgstr "Классы должны быть общедоступными, таким образом они могут быть исползованы всеми ботами в любой миссии. Члены класса также должны быть общедоступными, тоесть должны быть доступны за пределами класса. Членами класса могут быть ячейки и функции (по-другому методы), например следующий класс MyClass содержит 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 (x=3.33). 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 "ак показано в данном примере члены класса могут быть инициализированы (x=3.33). Вы можете также определить конструктор, который представляет собой специальный метод, имеющий то же имя, как и имя класса. Этот метод будет вызван автоматически в момент создания экземпляра класса. Вы можете также объявить более одного метода с тем же именем, но с разными параметрами." - -#. 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 MyClass, 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 a et b we must use the this.a and this.b to avoid confusion with the parameters. Another more simpler solution would be to give different names to the parameters." -msgstr "В этом примере два конструктора были объявлены как MyClass, один без параметров и второй с двумя параметрами. Поскольку имена параметров второго конструктора такие же, как и имена двух членов a и b мы должны использовать this.a и this.b чтобы избежать путаницы с параметрами. Наболее простым решением было бы дать разные имена параметрам." - -#. 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 void 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 "Вы также можете определить деструктор. Это должна быть пустая(void) функция без параметров, имеющая то же имя, что и класс, но с первиксом ~. Деструктор вызывается автоматически, как только класс уже больше никому не понадобится." - -#. 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 function, the function only receives a reference 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 function, the function only receives a reference 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 "" -"public, private, static, synchronized, new, reference, this\n" -"Programming, types and categories." -msgstr "" -"Общедоступное, приватное, статичное, синхронизированное, новое, ссылка, это\n" -"Язык CBOT и Переменные и категории." - #. type: \b; header #: ../E/close.txt:1 #, no-wrap @@ -8285,3 +8121,258 @@ msgid "" " Target1 Flying target\n" " AlienNest Alien Nest" msgstr "" + +#. type: Plain text +#: ../E/class.txt:10 +#, no-wrap +msgid "Classes can be only public. 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 (variables) and methods (functions)." +msgstr "" + +#. type: Plain text +#: ../E/class.txt:15 +#, no-wrap +msgid "For example, the following class dubbed MyClass contains 4 fields (a, b, x and s) and one method (MyFunction)." +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:" +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 a and b, we must use the this reference 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 YourClass using the new 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 reference. This means that when an object is passed to a 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." +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 extends 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 this" +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 void fonction without parameters, which has the same name as the class but prefixed with the ~ 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 . operator. Example:" +msgstr "" + +#. type: Plain text +#: ../E/class.txt:50 +#, no-wrap +msgid "Class members are public by default, which means that they are accessible outside of the class definition. They can also be declared as private or protected. 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 static. Methods can be additionaly declared as synchronized." +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 (int x = 3.33;)." +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 creation time of a class instance. Constructors can be overloaded." +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 "" +"public, private, protected, static, synchronized, new, reference, this, super, extends\n" +"Programming, types and categories." +msgstr ""