Make your own free website on Tripod.com

Documentation for Flip-Flops applet

 

Gates : class

Main class for the applet.

The background color is set and a canvas object is created by setting its size and adding it to the applet.

Set up for applet background.

No return value.

 

Canvas1 : class

Checks whether the mouse pointer is on any of the input switches.

This method iteratively scans each input switch and sees if the mouse pointer is on that switch. If the mouse is found to be on a switch, the method returns.

Inputs : x and y coordinates of mouse position.

Returns : Switch number (0 onwards) if mouse is on a switch

'20' if mouse is not on a switch.

 

FlipFlop : class

Represents the flip-flop completely.

Indicates the type of flip-flop (0 - D, 1 - SR, 2 - JK)

Indicates how many inputs the flip-flop has.

Stores the inputs for the flip-flop (either 0 or 1).

Stores the output (Q) of the flip-flop.

Draws the flip-flop on screen alongwith input and output switches (by calls to the next 2 methods).

A switch structure is used which checks the type of the flip-flop and depending on the type the flip-flop is drawn using the Graphics object.

Takes as input the Graphics object created in the Canvas1 class.

Draws the input switch.

The input switch is drawn at the appropriate location using the value of ‘input’. The color of the switch is selected from an array ‘colors’ which stores the colors red and green. Depending on the value of the input the color is selected from the array.

Inputs : The Graphics object created in the Canvas1 class.

The input switch to be drawn (1 or 2)

Draws the output switches (Q and ~Q).

The input switch is drawn at the appropriate location. The color of the switch is selected from an array ‘colors’ which stores the colors red and green. Depending on the value of ‘output’ the color is selected from the array.

Takes as input the Graphics object.

Computes the output of the flip-flop for the inputs at that instant.

This method uses a switch structure which checks the type of the flip-flop and depending on this type it applies the appropriate logic rule for that flip-flop to compute the output for the particular inputs.

Draws the truth table for all 2 input flip-flops.

Checks the type of the flip-flop and draws the truth table by filling it with values which are provided.

Takes as input the Graphics object.

Draws the truth table for the D Flip-Flop.

Takes as input the Graphics object.