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

2013/10/21

This must be first call in construtor

ddvink ddvink

2013/10/21

#
    public TrainingGround()
    {   

        super(1600, 1000, 1); 
        this(500, 500);
Well.... which one has to be the first? What's the solution for this? Yours, Dennis
Gevater_Tod4711 Gevater_Tod4711

2013/10/21

#
Well both have to be first I think. But you don't need both of them. If you call this(...) you can call super in the second constructor which you call using this. So you can avoid this problem.
SPower SPower

2013/10/21

#
You can only have a super or a this statement, not both. This would be a solution:
public TrainingGround()
{
    this(500,500);
}

public TrainingGround(int arg1, int arg2)
{
    super(1600,1000,1);
    // other stuff
}
ddvink ddvink

2013/10/21

#
thanks!
You need to login to post a reply.