Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions doc/03-component-interfaces/03-component-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`).

<!-- TODO: make a diagram of your component hierarchy then delete this comment -->
![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
Expand All @@ -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).

<!-- TODO: make a new branch from main then delete this comment -->

## Assignment Tasks

Your primary task for this assignment is to draft two interfaces in line with
Expand Down Expand Up @@ -208,8 +206,6 @@ request merge (or at least tag your commits). This is not required.

### Submission

<!-- TODO: read the submission instructions then delete this comment -->

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
Expand Down Expand Up @@ -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.

<!-- TODO: follow the link to share your feedback then delete this comment -->

[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
Binary file added doc/03-component-interfaces/interfaceHiearchy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions src/LogicGates.java

This file was deleted.

8 changes: 0 additions & 8 deletions src/LogicGatesKernel.java

This file was deleted.

37 changes: 37 additions & 0 deletions src/components/logicgates/LogicGates.java
Original file line number Diff line number Diff line change
@@ -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();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, but it would be nice to able to also replace the inputs. Gates are nicer when they're reusable/modular.

59 changes: 59 additions & 0 deletions src/components/logicgates/LogicGatesKernel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package components.logicgates;

import components.standard.Standard;

/**
* Logic Gates kernel component with its primary methods.
*/
public interface LogicGatesKernel extends Standard<LogicGates> {

/**
* 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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use an enum for this.

* 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();
}