/** This is a class for a toy that might be in a simulation similar to the phone system. This shows the use of some simple html tagging. Of course the basics of javadoc have been given you in the Demo1 pages.

@author R. P. Futrelle @version 1.0 5/24/01

The all-important step() function calls on the following modules:

The major set of actions performed on the toy, its public methods, are the following:

**/ public class Toy { boolean toMove; boolean toSpeak; boolean toWiggle; boolean toGrimace; boolean toPush; boolean toCarry; boolean toPickup; boolean toPutDown; /**

This calls the following modules:

(The above repeats material in the class comments, but that may be helpful -- may not.)

In this imaginary example, I assume that actions are controlled by flags which are in turn set by the various methods called by step() and by calls to the public methods of the class. You can clearly see that this makes step() very simple. If any of your methods start to become complex and have too many different tasks being done, all in the same method, it is best to divide up those tasks into calls to other (private) methods that you define. An example in step() below that uses an if-else construction shows this.

**/ public void step() { if(toMove) moveMe(); if(toSpeak) speak(); if(toWiggle) wiggle(); if(toGrimace) grimace(); if(toPush) push(); if(toCarry) carry(); else { if(toPickup) pickup(); if(toPutDown) putDown(); } } /** * Allows a user to wind up the toy to give * it energy for its actions. * (Note the use of param and return tags, * but only at the end of the javadoc comments for * the method.) * @param howMuch A value between 0.0 and 100.0 * which is what fraction of its total windup you * wish to add -- values outside this range are * truncated to this range. * @return The amount of windup the toy now has * after this latest windup -- never greater than 100.0. **/ public double windup(double howMuch) { return 0.0; } public void set(){} public void turnOnOff(){} public void move(){} private void moveMe(){} private void speak(){} private void wiggle(){} private void grimace(){} private void push(){} private void carry(){} private void pickup(){} private void putDown(){} }