package obj;

import classes.Signal;
import classes.Signal.EventState;

public class Factory implements Runnable {
	
	private Signal		factoryStore;		// reference to signal between this factory and Store
	private int inventory;
	private int inventoryCap;
	public Factory(int id, Signal factoryStore) {
		this.factoryStore = factoryStore;
		inventory = 0;
		inventoryCap = 200;
	}
	
	public Factory(int id, Signal factoryStore, int startingInventory, int startingCap) {
		this.factoryStore = factoryStore;
		inventory = startingInventory;
		inventoryCap = startingCap;
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		while (true)
		{
			factoryStore.await(EventState.TICK);
			if (inventory == inventoryCap || inventory+20 >= inventoryCap)
			{
				continue;
			}
			inventory += 20;
			
		}
	}

}

@@ -562,16 +562,69 @@
 gCap;%0A%09%7D
+%0A%09public int getinventory()%0A%09%7B%0A%09%09return inventory;%0A%09%7D
 %0A%0A%09@Over
@@ -859,12 +859,8 @@
 20;%0A
-%09%09%09%0A
 %09%09%7D%0A

add get inventory to factory class