diff --git a/CHANGELOG.md b/CHANGELOG.md index 1704bc9..765e7e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ the following form: YYYY.0M.0D. ### Updated -- Changed design to better model complex logical gate sequences by implementing design choices similar to binary trees. +- Changed design to better model complex logic gate sequences through binary tree structures. ## 2025.10.17 diff --git a/doc/03-component-interfaces/03-component-interfaces.md b/doc/03-component-interfaces/03-component-interfaces.md index 4156c6b..65e1a21 100644 --- a/doc/03-component-interfaces/03-component-interfaces.md +++ b/doc/03-component-interfaces/03-component-interfaces.md @@ -130,7 +130,7 @@ hierarchy diagram using whatever tools you would like. Then, include a picture of it in this folder. You may also embed it just below using markdown syntax (i.e., `![ALT TEXT](path/to/file)`). - +![logicGatesHieracrchy](interfaceHiearchy.png) To start making your interfaces, make a branch off of main in your new repo called something like `interfaces`. There are many ways to do this, but my @@ -152,8 +152,6 @@ to see them. If you don't like this workflow, you may try following the rebase strategies described [here](https://stackoverflow.com/questions/35790561/working-while-waiting-for-pending-pr) and [here](https://stackoverflow.com/questions/18021888/continue-working-on-a-git-branch-after-making-a-pull-request). - - ## Assignment Tasks Your primary task for this assignment is to draft two interfaces in line with @@ -208,8 +206,6 @@ request merge (or at least tag your commits). This is not required. ### Submission - - Assuming that your project is in a GitHub repo somewhere and your changes are on a proof-of-concept branch, then what we'll want you to do is create a pull request of all your changes. Pull requests are pretty easy to make if you're @@ -258,8 +254,6 @@ If you'd like to give feedback for this assignment (or any assignment, really), make use of [this survey][survey]. Your feedback helps make assignments better for future students. - - [natural-number-kernel]: https://web.cse.ohio-state.edu/software/common/doc/src-html/components/naturalnumber/NaturalNumberKernel.html [natural-number]: https://web.cse.ohio-state.edu/software/common/doc/src-html/components/naturalnumber/NaturalNumber.html [survey]: https://forms.gle/dumXHo6A4Enucdkq9 diff --git a/doc/03-component-interfaces/interfaceHiearchy.png b/doc/03-component-interfaces/interfaceHiearchy.png new file mode 100644 index 0000000..0e0ca08 Binary files /dev/null and b/doc/03-component-interfaces/interfaceHiearchy.png differ diff --git a/src/LogicGates.java b/src/LogicGates.java deleted file mode 100644 index c2ee57e..0000000 --- a/src/LogicGates.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * {@code LogicGatesKernel} enhanced with secondary methods. - */ -public interface LogicGates extends LogicGatesKernel { - -} diff --git a/src/LogicGatesKernel.java b/src/LogicGatesKernel.java deleted file mode 100644 index 63e630b..0000000 --- a/src/LogicGatesKernel.java +++ /dev/null @@ -1,8 +0,0 @@ -import components.standard.Standard; - -/** - * Logic Gates kernel component with its primary methods. - */ -public interface LogicGatesKernel extends Standard { - -} diff --git a/src/components/logicgates/LogicGates.java b/src/components/logicgates/LogicGates.java new file mode 100644 index 0000000..6de02e4 --- /dev/null +++ b/src/components/logicgates/LogicGates.java @@ -0,0 +1,37 @@ +package components.logicgates; + +/** + * {@code LogicGatesKernel} enhanced with secondary methods. + */ +public interface LogicGates extends LogicGatesKernel { + + /** + * Reports the operator of {@code this}. + * + * @return the operator of {@code this} + * @requires this \= empty + * @ensures this = compose(operator, left, right) + */ + String operator(); + + /** + * Replaces the operator of {@code this} with {@code op}, and returns the + * old operator. + * + * @param op + * the new operator + * @return the old operator + * @requires this \= empty + * @ensures (this = compose(op, left, right) and #this = + * compose(replaceOperator, left, right)) + */ + String replaceOperator(String op); + + /** + * Returns the height of {@code this}. + * + * @return the height + * @ensures height = ht(this) + */ + int height(); +} diff --git a/src/components/logicgates/LogicGatesKernel.java b/src/components/logicgates/LogicGatesKernel.java new file mode 100644 index 0000000..2a7d7a6 --- /dev/null +++ b/src/components/logicgates/LogicGatesKernel.java @@ -0,0 +1,59 @@ +package components.logicgates; + +import components.standard.Standard; + +/** + * Logic Gates kernel component with its primary methods. + */ +public interface LogicGatesKernel extends Standard { + + /** + * Assembles in {@code this} a logic gate {@code operator} and input values + * {@code first} and {@code second}. + * + * @param operator + * the logical operator + * @param first + * the first input value + * @param second + * the second input value + * @requires operation to be equal to one of the following operators: {AND; + * OR; NAND; NOR; XOR; NEG} + * @replaces this + * @ensures this = compose(operator, first, second); + */ + void assemble(String operator, boolean first, boolean second); + + /** + * Disassembles {@code this} into the logic gate {@code operator}, which is + * returned as the value of the function, and input values {@code first} and + * {@code second}. + * + * @param first + * the first input value + * @param second + * the second input value + * @return logical operator + * @replaces left, right + * @requires this /= empty + * @ensures this = compose(disassemble, first, second); + */ + String disassemble(boolean first, boolean second); + + /** + * Computes the final boolean value for the entirety of {@code this}, and + * returns said boolean. + * + * @return the final boolean value + * @ensures compute = compute(first) operator compute(second) + */ + boolean compute(); + + /** + * Returns the size of {@code this}. + * + * @return the size + * @ensures size = |this| + */ + int size(); +}