#include <iostream>
#include <chrono>
#include "ConveyorBelt.h"
#include "Machine.h"
using namespace std;

int main(){
	ConveyorBelt mainBelt;
	Machine assembler("Assembler",1);
	Machine painter("Painter",2);
	Machine packager("Packager",1);
	for(int i=0; i<100; i++){
		Product p(i);
		mainBelt.addProduct(p);
	}
	cout <<"Products on belt: "<<mainBelt.getCount()<<endl;
	auto start_time=chrono::high_resolution_clock::now();
	cout<<"Factory is starting..."<<endl;
	while(mainBelt.getCount()>0){
		Product currentItem=mainBelt.getNextProduct();
		assembler.process(currentItem);
		painter.process(currentItem);
		packager.process(currentItem);
	}
	auto end_time=chrono::high_resolution_clock::now();
	chrono::duration<double> total_time=end_time-start_time;
	cout<<"Factory finished in: "<<total_time.count()<<" seconds."<<endl;
	return 0;
}
