All pastes #233740 Raw Edit

Dan

public java v1 · immutable
·published 2006-11-02 03:08 UTC
rendered paste body
	/* 	 * 			SIMULATION	 */		public void Simulation(int nbMinutes, long seed, int nombreAvocats){		Random generateur = new Random(seed);		Avocat tempAvocat;						for(int numAvo=0;numAvo<nombreAvocats;numAvo++){			ajouterAvocat(new Avocat("Avocat"+ numAvo));//cle = numero avocat			}		for(int minute=0;minute<nbMinutes;minute++){			if(generateur.nextDouble() <= 0.125){ // Une chance sur 8 [12.5%]				if(generateur.nextDouble() <= 0.10){ // Une chance sur 10 [10%]					tempAvocat = avocats.get((String)(generateur.nextInt(nombreAvocats-1 /*empeche d'avoir un avocat :(*/) + "")); 					Appel a = new Appel("Mr."+minute,minute+ "");					tempAvocat.ajouterAppel(a);					compteurAppels++;					} else {					fileCommune.enfiler(new Appel("Mr."+minute,minute+""));					compteurAppels++;				}							}			for(int na = 0;na<nombreAvocats;na++){				tempAvocat = avocats.get((String)(na + ""));				if(!tempAvocat.estDisponible()){					if(tempAvocat.minuteAppelFini == minute){						tempAvocat.changerDisponibilite(true);					}				}				//On utilise pas de else ici parce que dans la sequence du for c'est possible d'etre vrai aux deux if s.				if(tempAvocat.estDisponible()){					if(tempAvocat.prochainAppel() != null){ 						tempAvocat.minuteAppelFini = generateur.nextInt(21) + minute + 14;						tempAvocat.changerDisponibilite(false);						compteurAppels--;					} else if(fileCommune.defiler() != null){						tempAvocat.minuteAppelFini = generateur.nextInt(21) + minute +14;						tempAvocat.changerDisponibilite(false);						compteurAppels--;					}													}							}		}		javax.swing.JOptionPane.showMessageDialog(null, "il reste " + compteurAppels + " d'appels a faire.");	/*	 * 			Inserer ici le code pour l'avocat de soir.	 */	}