This site requires JavaScript, please enable it in your browser!
Greenfoot back
K_O_P
K_O_P wrote ...

2012/5/31

Reference to TriggerManager is ambiguous

K_O_P K_O_P

2012/5/31

#
By compiling my scenario I get an error: reference to TriggerManager is ambiguous And I can't find the problem:
    private TriggerManager[] TriggerManager=new TriggerManager[2];
    private Trigger[] TrigSwitch=
        {
            new Trigger(Trigger.TriggerVariation[89]),
            new Trigger(Trigger.TriggerVariation[51]),
        };

    public void TriggerInitialization()
    {
        Trigger
        Control=new Trigger(Trigger.TriggerControl[6]),
        Recall=new Trigger(Trigger.TriggerRecall[4]),
        Trig1=new Trigger(Trigger.TriggerVariation[0]),
        Trig2=new Trigger(Trigger.TriggerVariation[0]),
        Trig3=new Trigger(Trigger.TriggerVariation[0]),
        Trig4=new Trigger(Trigger.TriggerVariation[1]),
        Trig5=TrigSwitch[0],
        Trig6=TrigSwitch[1];

        this.TriggerManager[0]=new TriggerManager(Recall,Control,Trig1,Trig2,Trig5,Trig6);
        this.TriggerManager[1]=new TriggerManager(Recall,Control,Trig3,Trig4,Trig5,Trig6);
    }
The 20th line is marked...
Busch2207 Busch2207

2012/5/31

#
Could you post the part of the class TriggerManager, where the constructors are written?
K_O_P K_O_P

2012/5/31

#
Here are they:
    public TriggerManager(Trigger Recall,Trigger Control,Trigger... ToBeActivated)
    {
        setTriggerControl(Control);
        setTriggerRecall(Recall);
        setActivate(ToBeActivated);
    }

    public TriggerManager(Trigger Recall,Trigger... ToBeActivated)
    {
        setTriggerControl(null);
        setTriggerRecall(Recall);
        setActivate(ToBeActivated);
    }
but this class compiles without problems...
danpost danpost

2012/5/31

#
Try going with convention, and begin your variable names with lowercase letters. Change the name of your array of TriggerManager objects to 'triggerManager'. That may get rid of the error. Or, if you prefer to keep it capitalized, change it to 'TriggerMgr'.
Busch2207 Busch2207

2012/5/31

#
No thats not the problem. Your problem is with the constructors. You've got TriggerManager(Trigger Recall, Trigger Control, Trigger... Activated) and TriggerManager(Trigger Recall,Trigger... Activated) Now if you write: new TriggerManager(Trig1, Trig2, Trig3, Trig4) this would fit in both constructors. In the first case you would have Trig1 in Recall ,Trig2 in Control and Trig3 and Trig4 in Activated... In the second case you would have Trig 1 in Recall and Trig2, Trig3 and Trig4 in Activated. So the compiler don't know, which constructor he has to take now... So you has to think about another solution ;) In my opinion you would not need the second constructor, cause you could although enter: new TriggerManager(Trig1, null, Trig2, Trig3, Trig4)
You need to login to post a reply.