Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by munchie (Monk)
on Mar 21, 2002 at 01:04 UTC ( [id://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)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-24 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found