Collaboration Method to Return String of Circuit Elements - Wait-For-It-123/logiCAD GitHub Wiki

Reviewer/Contact: Ian Wilson

The task is to write a method in Model.java that returns a String that lists all Gates, Inputs, and Outputs that currently exist in the workspace (all elements contained in the workspaceElements variable in Model.java) by type and id. The order of listing the circuit elements does not matter.

The method takes in no parameters and returns a String. The signature for the method is:

public String workspaceElementsToString()

The method stub has already been created for you in Model.java. It begins at line number: 64.

The String that you form should have the following format:

<object type of element_0><space><id of element_0><newline>
<object type of element_1><space><id of element_1><newline>
.
.
.
<object type of element_n><space><id of element_n>

For example, if workspaceElements currently contains two andGate objects whose ids are "and0" and "and1", a single Input object whose id is "in0" and a single Output object whose id is "out0", your String could look like:

andGate and0
andGate and1
Input in0
Output out0

Alternatively, because order does NOT matter, the String could look like:

Output out0
andGate and1
Input in0
andGate and0

What DOES matter though, is that the type on any line corresponds to an id of the appropriate type. For example, if the following pair were to be on any line of the String, the String would be incorrect (because all Input objects have an id that begins with "in" and all ids with "or" belong to orGate objects):

Input or3

For additional clarification on what other methods or variables do, contain, or how to use them, see the "Model (Explanation of Model.java)" page in the Wiki. Pay careful attention to the section explaining the workspaceElements variable (at the top of the page).

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