Jump to content
  • Advertisement
Sign in to follow this  
Concentrate

Quick Java question

This topic is 3160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can you check if this code is bugged, because I think it is but am not sure :
public PlayField(){
        _parentEllipse = new GenerateEllipse(_paintBox);
        _parentRect = new GeneratesRect();
        _parentRoundedRect = new GenerateRoundedRect();

        _paintBox = new PaintBox(_parentEllipse,_parentRoundedRect,_parentRect);
    }

The problem is that _paintBox has not been instantiated yet as you can see. How can I get _parentEllipse to have a refrence to _paintBox, while the _paintBox has a reference to _parentEllipse.

Share this post


Link to post
Share on other sites
Advertisement
Well, yeah - if _paintBox isn't instantiated, you're passing a null reference to the GenerateEllipse constructor - which is either useless or problematic, depending on what GenerateEllipse does with the parameter. Either way, it won't point to the instance of PaintBox you then precede to assign to _paintBox.

Are these classes you have developed? I can't find any documentation on them, though admittedly I didn't look very hard.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!