class Posti
{
	int posto[MAX];
public:
	int trovaEBloccaPosto(int codiceutente)
	{
		for(int i =0; i < MAX; i++)
			if (posto[i] == 0)
			{
				posto[i] = codiceutente;
				return i;
			}
		return -1;
	}
};

Posti* posti;

class BancoCheckin : public JTCThread

{
	int codiceBanco;
public:
	BancoCheckin (int cod)
	{ codiceBanco = cod; }
	virtual void run()
	{
		while(true)
		{
		   sleep(100);
			int codiceutente = rand() % 10000;
		   int posto
		     = posti->trovaEBloccaPosto(codiceutente);
        	cout << "Banco checkin:" << codicebanco <<endl;
		   if (posto > 0)
        	{
        		cout << "Prenotato posto:" << posto;
        	}
        	else
        		cout << "Utente: " << codiceutente <<
        		"non c'è posto per te.";
		}
	}
};

int main()
{
	posti = new Posti();
    BancoCheckin *a = new BancoCheckin(1);
    BancoCheckin *b = new BancoCheckin(2);
    BancoCheckin *c = new BancoCheckin(3);
    a->start();
    b->start();
    c->start();
    return 0;
}

