Index: phpdoc/hu/language/oop.xml
diff -u phpdoc/hu/language/oop.xml:1.1 phpdoc/hu/language/oop.xml:1.2
--- phpdoc/hu/language/oop.xml:1.1 Wed Aug 9 08:03:31 2000
+++ phpdoc/hu/language/oop.xml Sun Oct 29 08:22:11 2000
@@ -1,29 +1,30 @@
- Osztályok és objektumok
+ Osztályok, objektumokclass
- A class is a collection of variables and functions working with
- these variables. A class is defined using the following syntax:
-
+ Az osztály (objektumtípus) változók és rajtuk műveletet végző
+ függvények [metódusok] együttese. Osztályt az alábbi szintakszis szerint lehet
+ definiálni:
-<?php
-class Cart {
- var $items; // Items in our shopping cart
+items[$artnr] += $num;
+ function berak ($sorsz, $db) {
+ $this->dolgok[$sorsz] += $db;
}
- // Take $num articles of $artnr out of the cart
+ // kivesz a kosárból $db darabot az $sorsz indexű dologból
- function remove_item ($artnr, $num) {
- if ($this->items[$artnr] > $num) {
- $this->items[$artnr] -= $num;
+ function kivesz ($sorsz, $db) {
+ if ($this->items[$sorsz] > $db) {
+ $this->items[$sorsz] -= $db;
return true;
} else {
return false;
@@ -31,119 +32,141 @@
}
}
?>
+]]>
- This defines a class named Cart that consists of an associative
- array of articles in the cart and two functions to add and remove
- items from this cart.
-
+ Ez definiál egy Kosar nevű osztályt, ami a kosárban levő áruk
+ asszociatív tömbjéből áll, és definiál 2 funkciót hozzá, hogy
+ bele lehessen rakni, illetve kivenni a kosárból.
+
+
+ PHP 4-ben csak konstans var inicializáló
+ értékek megengedettek. Használd a konstruktort nem konstans
+ értékű inicializáláshoz.
+
- Classes are types, that is, they are blueprints for actual
- variables. You have to create a variable of the desired type with
- the new operator.
+ Az osztályok típusok, vagyis az aktuális változók tervrajzai.
+ A kívánt típusú változót a new operátorral hozhatod létre.
- $cart = new Cart;
- $cart->add_item("10", 1);
+ berak("10", 1);
+ ]]>
+
+ Ez létrehozza a Kosar objektumosztály $kosar nevű objektumpéldányát.
+ Az objektum berak() függvényét meghívtuk, hogy a 10-es számú árucikkből
+ rakjon 1 darabot a kosárba.
+
- This creates an object $cart of the class Cart. The function
- add_item() of that object is being called to add 1 item of article
- number 10 to the cart. Classes can be extensions of
- other classes. The extended or derived class has all variables and
- functions of the base class and what you add in the extended
- definition. This is done using the extends keyword. Multiple
- inheritance is not supported.
+ Osztályok származhatnak más osztályoktól is (öröklés).
+ A leszármazott osztály az ős minden változóját és függvényét
+ [metódusát] örökli. Erre használható az extends kulcsszó.
+ A többszörös öröklés nem támogatott [:( vagyis egy gyereknek több őst nem
+ nevezhetünk meg. A tranzitív öröklés azonban megengedett].
-class Named_Cart extends Cart {
- var $owner;
+owner = $name;
+ function tulajdonosa ($nev) {
+ $this->tulaj = $nev;
}
}
+]]>
- This defines a class Named_Cart that has all variables and
- functions of Cart plus an additional variable $owner and an
- additional function set_owner(). You create a named cart the usual
- way and can now set and get the carts owner. You can still use
- normal cart functions on named carts:
+ Ez definiál egy Gazdas_Kosar nevű osztályt, ami a Kosar összes
+ változójával és metódusával rendelkezik, és van egy saját változója,
+ a $tulaj, no meg egy saját metódusa, a tulajdonosa().
+ A gazdás kosarat a hagyományos módon hozhatod létre, és a kosár
+ tulajdonosát is be tudod állítani, le tudod kérdezni [ebben
+ az esetben favágó módszerrel]. A gazdás kosarakon továbbra is
+ lehet használni a Kosar függvényeit:
-$ncart = new Named_Cart; // Create a named cart
-$ncart->set_owner ("kris"); // Name that cart
-print $ncart->owner; // print the cart owners name
-$ncart->add_item ("10", 1); // (inherited functionality from cart)
+tulajdonosa ("Namilesz Teosztasz"); // a tulaj beállítása
+print $gkosar->tulaj; // a tulajdonos neve
+$gkosar->break ("10", 1); // (Kosar-ból öröklött funkcionalitás)
+]]>
- Within functions of a class the variable $this means this
- object. You have to use $this->something to access any variable or
- function named something within your current object.
+ Osztályok függvényein belül a $this a manipulálandó objektumpéldányt jelenti.
+ A $this->valami formát kell használnod az aktuális objektum valami nevű
+ változó vagy metódus elérésére.
- Constructors are functions in a class that are automatically
- called when you create a new instance of a class. A function
- becomes a constructor when it has the same name as the class.
+ A konstruktorok olyan az osztályok olyan metódusai, amelyek
+ automatikusan meghívódnak, amikor létrehozol egy új objektumpéldányt.
+ Egy függvény [metódus] úgy lesz konstruktor, ha a neve megegyezik
+ az osztály nevével.
-class Auto_Cart extends Cart {
- function Auto_Cart () {
- $this->add_item ("10", 1);
+berak ("10", 1);
}
}
+]]>
- This defines a class Auto_Cart that is a Cart plus a constructor
- which initializes the cart with one item of article number "10"
- each time a new Auto_Cart is being made with "new". Constructors
- can also take arguments and these arguments can be optional, which
- makes them much more useful.
+ Ez egy olyan Auto_Kosar nevű osztályt [objektumtípust] hoz létre,
+ mint a Kosar, csak rendelkezik egy konstruktorral, ami inicializálja
+ a kosarat 1 darab "10"-es áruval, valahányszor a new operátorral
+ hozzuk létre az objektumot. [de csak akkor!!!] A konstruktoroknak
+ is lehetnek paramétereik, és ezek lehetnek opcionálisak, ami még
+ hasznosabbá teszi őket.
-class Constructor_Cart extends Cart {
- function Constructor_Cart ($item = "10", $num = 1) {
- $this->add_item ($item, $num);
+berak ($sorsz, $db);
}
}
-// Shop the same old boring stuff.
+// Mindig ugyanazt az uncsi dolgot veszi...
-$default_cart = new Constructor_Cart;
+$kiindulo_kosar = new Konstruktoros_Kosar;
-// Shop for real...
+// Igazi vásárlás
-$different_cart = new Constructor_Cart ("20", 17);
+$masik_kosar = new Konstruktoros_kosar ("20", 17);
+]]>
- For derived classes, the constructor of the parent class is not
- automatically called when the derived class's constructor is
- called.
+ A leszármaztatott osztályokban a szülő osztály konstruktora
+ NEM hívódik meg automatikusan, amikor
+ a származtatott osztály konstruktorát meghívod.