[Bluej-discuss] Code Pad: is it working correctly?
Poul Henriksen
p.henriksen at kent.ac.uk
Wed Apr 19 15:25:10 BST 2006
Barry Brown wrote:
> I am using BlueJ on a Mac (10.4.6). I recently found out about the
> Code Pad where I can type in Java statements and have them executed.
> From what I read in the instructions, the objects I create should
> appear on the bench. But they don't.
>
> Here's what I've tried:
> Open the Shapes example project.
> Open the Code Pad.
> Type in something like: Circle c = new Circle();
>
> Should I see an object appear in the bench?
>
As Philippe correctly writes you have to drag the object onto the object
bench. In the above example you would have to write the following line
instead:
new Circle()
That will return a new circle object represented by a little red icon,
which you can drag onto the object bench. When you drop it on the object
bench you give it a name which can be used in the code pad.
> Another question: is there a way to "replay" the statements in the
> Code Pad? My students have been clamoring for a way to record a bunch
> of actions, similar to the way the JUnit testing recording works.
> Except in JUnit, all the objects that are creating during the test go
> away once the test is complete. Is there a way to create a bunch of
> objects and have them stay on the bench? That would save a lot of
> time when testing their programs. Doing the Auction project was a
> real pain because they kept having to create Persons, Auctions, Lots,
> and Bids over and over.
>
> If they write a method to create the objects, they won't appear on
> the bench.
>
> Is there a good built-in solution?
>
If you create a test class and right click it you will see two menu items:
1. Object Bench to Test Fixture: this will store the objects currently
on the object bench into the test class.
2. Test Fixture to Object Bench: this will restore any object to the
object bench which have been stored in the test class.
Cheers,
Poul Henriksen
More information about the bluej-discuss
mailing list