Quantcast
Channel: Questions in topic: "extending"
Viewing all articles
Browse latest Browse all 16

Extended class functions

$
0
0
Lets say i had a simple class that extends another class: class Item { private var name : String = "itemName"; private var price : int = 21; private var weight: int = 1; function _get(what:String){ if(what=="price")return price; if(what=="weight")return weight; } } class Weapon extends Item { private var damage : int = 10; private var speed : int = 5; function _get(what:String){ if(what=="damage")return damage; if(what=="speed")return speed; } } function Start () { var wep = new Weapon(); print(wep._get("damage"));//prints 10 print(wep._get("price")); //prints 0 ??? } The problem is - i can't seem to get the base class variables - price or weight in this example. Maybe there is a special way of extending a function? Any help would be appreciated.

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>