This is the syntax highlighted version of Circuit.java.
/*************************************************************************
* Compilation: javac Circuit.java
*
* ADT for circuit with M inputs and N outputs.
*
*************************************************************************/
public abstract class Circuit {
private Wire[] in; // input wires
private Wire[] out; // output wires
// construct a new circuit with M input wires and N output wires
public Circuit(int M, int N) {
in = new Wire[M];
out = new Wire[N];
for (int i = 0; i < M; i++) in[i] = new Wire(this);
for (int j = 0; j < N; j++) out[j] = new Wire(this);
}
protected Wire inAt(int i) { return in[i]; } // return the ith input wire
protected Wire outAt(int j) { return out[j]; } // return the jth output wire
public void propagate() { }
}
Last updated: Mon May 24 12:02:56 EDT 2004
.
Copyright © 2004, Robert Sedgewick and Kevin Wayne.