On Tuesday 13 Jan 2004 4:39 pm, Gary Stainburn wrote:
> On Tuesday 13 Jan 2004 3:04 pm, James Edward Gray II wrote:
> > On Jan 13, 2004, at 6:24 AM, Gary Stainburn wrote:
[snip]
> > > 1) I've put:
> > >
> > > use base (Trainset::Trains Trainset::Track Trainset::Signals
> > >     Trainset::Levers Trainset::Boxes);
> > >
> > > inside Trainset.pm. Is this the correct way to call in the other
> > > classes?
> >
> > No it's not.
> >
> > use Trainset::Trains;
> > use Trainset::Track;
> > use Trainset::Signals;
> > use Trainset::Levers;
> > use Trainset::Boxes;
> >
> > > If  so, would this also give Trainset::Boxes access to
> > > Trainset::Levers::add_lever to enable the shortcut I mentioned above?
> >
> > After you switch to the code above sure, but I'm not sure it needs to.
> > Trainset is the glue object.  Use it that way.  Trainsets'
> > add_signalbox() should create the box, create the lever(s) and link
> > them together.  Trainset::Boxes just needs to worry about itself, in
> > construction at least.
>
> So basically, within the add_signalbox would simply call $owner->add_lever
> asuming $owner points to the $tset object?
>

I'm starting to confuse myself again now.  I've got it into my head that I'm 
going to have an instance of Trainset as a holder to contain track, signals 
etc, so I'll do something line:

my $tset=Trainset->new;
$tset->add_track('TCB',['TCB1','TCB2']);

The problem here is that I'm using a Trainset object to call a method of 
Trainset::Track.  Now I thought that this would work because of inheritance, 
but it doesn't seem to work that way, and the only way I seem to be able to 
get it working is to use the exporter within Trainset::Track.  Isn't this 
defeating the object of inheritance, or am I missing something?

[snip]
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to