Inheritance vs. Composition : Composition : Class Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Class » Composition »

 

Inheritance vs. Composition


 
package
{
    public class House
    {
        public var kitchen:Kitchen;
        public var livingroom:LivingRoom;
        public var bedrooms:Array;

        public function House(numberOfBeds:int)
        {
            kitchen = new Kitchen();
            livingroom = new LivingRoom();
            bedrooms = new Array();
            for (var i:int 0; i < numberOfBeds; i++)
            {
                bedrooms[inew Bedroom();
            }
        }
    }

}
class Kitchen{
}
class LivingRoom{
}
class Bedroom{
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Class
» Composition