Polymorphism JAPH
- Details
- Category: Codigo
- Published on Monday, 21 March 2011 20:06
- Written by Cristian Vasquez Diaz
- Hits: 39
Concept : Educational OO Polymorphism practice with Japh La educacion es el principio de lo espontaneo
#!/usr/bin/perl
package J ;sub new{$__=shift and(%__)=@_ and bless{1,
$__{1}, },$__} package main; #Polymorphism J A P H
package A ;sub new{$__=shift and (%__)= @_ and($___)=
J->new( @_)and$___->{2}=$__{2}and bless($___,$__);}
package P ;sub new{$__=shift and (%__)= @_ and($___)=
A->new( @_)and$___->{3}=$__{3}and bless($___,$__);}
package H ;sub new{$__=shift and (%__)= @_ and($___)=
P->new( @_)and$___->{4}=$__{4}and bless($___,$__);}
$o=H->new (1,Just,2,Another,3,Perl,4,Hacker); print "$o->{
$_} " foreach sort keys %{ $o } ;# Educational Concept

