Interpretação de codigo

0 respostas
folex70

Ola a todos, por favor preciso de uma ajuda para interpretar esse codigo,, trata-se de um exemplo do uso de radom em j2me,, por favor me ajudem a entender esses trechos do codigo,, obrigado

public void setActive()
	{
		isActive=true;
		random = new java.util.Random();
//		(upperlimit +1 - lowerlimit) + lowerlimit;
		frameLength = ( random.nextInt() >>> 1) % (60 +1 - 40) + 40;
		int type = (random.nextInt() >>> 1) % 10;
		frameCount=4*frameLength;

		int []seq;
		seq = new int[frameCount];
		for (int i=0; i<4*frameLength;i++)
		{
			int frameNo=i/frameLength;
			if (frameNo>=2 && type%2==1)
			{
				frameNo+=2;
			}
			seq[i]=frameNo;
		}
		setFrameSequence(seq);

	}
private void tick() {
		int numActive=0;
		int cell;
		for (int i=0;i<maxBoxes;i++)
			if (box[i].active()) numActive+=1;

		if (numActive><4)
		{
			Random random = new java.util.Random();
			cell = ( random.nextInt() >>> 1) % 9;
			if (!box[cell].active())
			{
				box[cell].setActive();
				numActive+=1;
			}

Obrigado vlw

Criado 6 de maio de 2009
Respostas 0
Participantes 1