Week 1 — Logic Circuit Builder

Terminal Utility · Java


The Idea

Every processor, every digital circuit, every piece of computing hardware ultimately runs on one thing: boolean logic. AND, OR, NOT — combine these gates in the right way and you can build anything from a half adder to a CPU.

In this project you'll build a tool for constructing and evaluating logic circuits in the terminal. The user defines a circuit by connecting gates together, sets the input signal values, and the program evaluates the output — propagating the logic through the entire structure automatically.

What makes this project a beautiful fit for OOP is that a logic circuit is a tree of objects. Each gate takes inputs and produces an output. Those inputs can be other gates or raw signals. When you call evaluate() on the root gate, it recursively evaluates its inputs, which evaluate their inputs, all the way down to the signal leaves. The same method call, the same code path — different behaviour at every node.

You decide what gates you want to support, how the user builds a circuit, and what the output looks like. The only constraint is that you support at least four gate types and that evaluation works recursively without any type checks.


Week 1 — Build Your Gate Hierarchy

This week is about the gates and the signals — the raw building blocks of any circuit. No interactive builder yet, just the objects and the evaluation logic.

This week's topic: classes and subclasses.

There are two distinct kinds of nodes in a circuit: gates (which have inputs and logic) and signals (which are just named boolean values at the leaves). These are different enough that Signal should not extend Gate — they just happen to share the same capability of being evaluatable.

You need:

For this week, build a few hardcoded circuits in code and verify they evaluate correctly. For example: AND(OR(A, B), NOT(C)) — set A=true, B=false, C=false and check the output is true.

What you decide:

The interactive CLI for building circuits comes in later weeks — for now, hardcoded wiring is fine.