/** Procédure de paiement et de passage d'un véhicule */ @Override public synchronized void gererVehicule(VehiculeEvent vehicule) { if (borneDisponible()) { try { effectuerPaiement(); gestionAlarmes(vehicule.typePaiement()); if (borneDisponible()) { fairePasserVehicule(vehicule); } } catch (InterruptedException e) { e.printStackTrace(); } } }
public void envoyerRapport(VehiculeEvent vehicule) { if (_rapportListener != null) { double prixParKm = 0; switch (vehicule.typeVehicule()) { case CAMION: prixParKm = 0.2; break; case BUS: prixParKm = 0.15; break; case CARAVANE: prixParKm = 0.13; break; case MOTO: prixParKm = 0.08; break; case VOITURE: prixParKm = 0.12; break; case SPECIAL: prixParKm = 0; break; } int nombreKm = (new Random()).nextInt(500) + 1; double coeff = 1.0; if (_typeBorne == TypeBorne.TELEPEAGE) { coeff = 0.75; } double somme = coeff * prixParKm * nombreKm; RapportEvent rapport = new RapportEvent( this, vehicule.typeVehicule(), _numeroVoie, new Date(), somme, _typeBorne, vehicule.typePaiement()); _rapportListener.rapportEnvoye(rapport); System.out.println(rapport); } }