// © National University of Singapore. All rights reserved.

// Department of Computer Science
// National University of Singapore
// 3, Science Drive 2, Singapore 117543
// Tel: (65) 874 2830 Fax: (65) 779 4580

import spades_Java.*;

public class SimWork1 extends Executive {
	Customer cust;
	Resource res1, res2, res3;

	public void init()
	{
		res1 = new Resource("Counter 1", 20, 0);
		res2 = new Resource("Counter 2", 15, 0);
		res3 = new Resource("Counter 3", 20, 0);
		cust = new Customer(this);
		activate(cust, 0.0);
	}

	public static void main(String[] args)
	{
		SimWork1 s = new SimWork1();
		s.initialize(args.length, args);
		s.startSimulation(100, 0);
	}
}

class Customer extends SProcess {
	SimWork1 sw;

	public Customer(SimWork1 s)
	{	sw = s;}

	public void run()
	{
		System.out.println(getName()+" is coming at time "+simClock);
		Customer next = new Customer(sw);
		activate(next, 5.0);
		work(sw.res1, 4, 2);
		wait(4.0);
		work(sw.res2, 3, 1);
		wait(5.0);
		work(sw.res3, 6, 4);
		terminate();
	}
}
