Miscellaneous Classes - Wait-For-It-123/logiCAD GitHub Wiki

Gate class (abstract class)

  • Gate class implements interfaces In and Out (note: Out is never used)
  • The gate class has variables for the two input values and one output value for a logic gate.
  • It has two lists that keep track of all the children that the gate's output signal flows into. One list (outputsIntoInputs1) keeps track of children into which the output signal flows into its first input, while the other list (outputsIntoInputs2) keeps track of those children into which the output signal flows into their second input.
  • Every gate keeps track of its ancestors in a familyTree list.
  • It has variables for the gate's id, and coordinates.
  • Important methods are:
    • public int evaluateInputSignals(), which performs the applicable logic operation on the inputs and returns the result
    • public int setInput(Object input), which sets an input object and returns an int corresponding to the input to which the connection was made. See the method comments for clarification about the int return value.
    • public void setChild_Inputs1(Object newChild) and public void setChild_Inputs2(Object newChild), which add an object to the outputsIntoInputs1 or outputsIntoInputs2 lists respectively.

The following concrete classes inherit from Gate class:
notGate -- note: notGate only uses one of the two inputs (input 1), while other gates use two
andGate
orGate
nandGate
norGate
xorGate
xnorGate

Input Class
The input class provides input values / signals to the circuit. It is a parent to any gate it is attached to. It is not possible for an Input to have ancestors (its familyTree is always empty). The Input class can have arbitrary number of children, and the children are stored in two lists (similar to Gate class above), but the names of the lists are different (childrenInputs1 and childrenInputs2). The value for input can be set from 1 to 0 or from 0 to 1.

Output Class
The output class displays the final output signal values of the circuit element it is connected to. An output can have at most one input source and can have no children. An output can take in the values of 1 or 0 as a signal. The method public int setInput(Object input) is used to set the output object's input source, and returns a 4 if connection is successful and 0 if not successful.

Wire Class
This class bundles three line segments of type Line2D into one package. Each wire in LogiCAD forming a connection is composed of three line segments.

ImageCoordAndType Class
This class holds the circuit element type, corresponding image, center coordinates, upper left coordinates, and buffer coordinates. This object tells the workspace what image to show when a circuit element is placed and gives the bounds (in pixels) of the displayed image. It also has the buffer space around the image in which no other image can be placed. The image bounds are used for circuit element selection for performing operations such as connect and delete.

Connection Class
This class packages a circuit connection of a parent circuit element and child circuit element along with the child input type into a single entity. Parent and child are stored by their String ids.

⚠️ **GitHub.com Fallback** ⚠️