![]() |
|
go ahead... be a heretic | |
PerlMonks |
Re: Trouble getting started with Perl OOby pernod (Chaplain) |
on Oct 07, 2004 at 12:08 UTC ( #397271=note: print w/replies, xml ) | Need Help?? |
Well, there are several things that come to mind here. First off, you don't store the parameter hash you're giving the object in the constructor (actually you could bless the hash itself, but this is a bit beside the point). I would change the constructor to the following:
Secondly, you're only making an object, not actually asking it to do anything. To get it to print, you have to callt the print_shape method:
Thirdly, your print_shape is a bit odd, in that it only will print the first line of the shape, not the entire shape. To print the entire box, you would have to iterate through the hash you've stored in shape, but then you'll lose your ordering. Lastly, to develop on the point of the print_shape, you should perhaps store some ordering information with the hash. As an alternative you could use an array instead of a hash, as this would retain the order of your lines. Eg:
This code is untested, of course. Good luck! pernod Update: Take a look at this node for an example discussion of the hornet's nest that is the copy-constructor. I realize that I was a bit impatient in my pointing to super search ...
In Section
Seekers of Perl Wisdom
|
|