/*
 * Created on Apr 4, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package ps6.v2;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author knorton
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Graph {
	private ArrayList		gates = null;
	private ArrayList		conns = null;
	
	public Graph() {
		this.gates = new ArrayList();
		this.conns = new ArrayList();
	}
	
	public void addGate(Gate g) {
		this.gates.add(g);
	}
	
	public void addConnector(Connector c) {
		this.conns.add(c);
	}
	
	public void step() {
		for (Iterator i = this.gates.iterator();i.hasNext();)
			((Gate)i.next()).update();
		
		for (Iterator i = this.gates.iterator();i.hasNext();)
			((Gate)i.next()).commit();
		
		for (Iterator i = this.conns.iterator();i.hasNext();) {
			Connector c = (Connector)i.next();
			if (c.isProbed())
				System.out.println(c);
		}
	}
}
