Programming in Java on Your Computer
- Classes and Objects in BlueJ
- Trying out Code in BlueJ
- The Code for Creating and Using Objects
- Source Code and Methods
- Accessors and Mutators
- Constructor Code
- Class Code
- Simple Debugging
- Interactive Picture
- Refactoring Code with Inheritance
Premium Content - Free Preview
In the previous node, you changed the Circle Class so Circles could be created with all of their instance variables set at a specific position. You can now improve your Picture Class to create a Picture in fewer lines of code.
Update your Picture code to create the same face as before but in fewer lines of code. Each Circle can now be created and set to the correct position and appearance in one line of code.
Previously, when you moved the Circles around to create a face, they didn't tell you what position they ended up in. This means you might not know what X and Y positions to use for them in the above task.
Often you will want to examine the variable values of a running program to see what's going on and what's broken. There are a few basic ways to do this:
- Debugger - A debugger is included with IDEs (including BlueJ) to let you step through code and examine the variable values. We won't cover using an IDE debugger right now, but you can use the visual debugger on Learneroo to debug your challenges. See the video below for more information.