Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: Beginner's Object Orientation Exercises?

by munchie (Monk)
on Mar 21, 2002 at 01:04 UTC ( #153180=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Beginner's Object Orientation Exercises?
in thread Beginner's Object Orientation Exercises?

I think that I could change

sub set_power { my $self=shift; my $power=shift; push @{$self->{POWERS}}, $power; } sub get_powers { my $self=shift; my $num=1; foreach my $power ( @{$self->{POWERS}} ) { print "$num => $power\n"; $num++; } print "\n"; }
into something like:
sub power { my $self=shift; if ($_[0]) { my $power=shift; push @{$self->{POWERS}}, $power; } else { my $self=shift; my $num=1; foreach my $power ( @{$self->{POWERS}} ) { print "$num => $power\n"; $num++; } print "\n"; } }
It would be called as $obj->power("Power name") to set, and $obj->power() to view.

> munchie, the number munchin newb
Llama: The other other white meat!
(you had to be there :-P)


Comment on Re: Re: Re: Beginner's Object Orientation Exercises?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://153180]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-07-25 13:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (171 votes), past polls