Experiment with the BlueJ projects we saw in lectures.
- Login with your zPass login and password.
- Download the ‘shapes’ project zip file from here .
- Download the ‘picture’ project zip file from here .
- Unzip both files in your “My Documents” folder.
- In the ‘Start’ menu, select ‘Programs’ and click on BlueJ.
- Select ‘Open Project’ from the File menu and open the ‘shapes’ project.
- Experiment with constructing objects and calling methods. Try to construct a picture out of circles, squares and triangles of different sizes and colours.
- Use the inspector to examine the objects you have created. How do the fields on a Triangle differ from those on a Circle?
- Double click on the Circle class to view its source code. Try to identify the fields and methods in the code. How much of the code can you understand?
- Open the ‘picture’ project and have a play with the new class it provides.
- Open the source code for the Picture class and take a look at the draw() method. This is the code that constructs the house from shapes.
- Change some of the method parameters and compile the source. Can you make the sun blue? Can you change the position of the window?
- Optional Challenge: Add code to the draw() method to make the sun set using the slowMoveVertical() method on the Circle class.
- Optional Extra Challenge: If you did the above challenge you probably found that the sunset happened as soon as the draw() method was called. Try creating a separate method called sunset() that does this instead.
No Comments so far ↓
There are no comments yet...Kick things off by filling out the form below.
You must log in to post a comment.