public void Verifier(Vehicule v) { int temps = random.Next(1, 4); for (int i = 0; i < temps; i++) { } Trajet trajetAssocie = gestionFlotte.TrajetList.Find(trajet => trajet.NTrajet == v.NTrajet); Intervention intervention; Intervention.TryParse(random.Next(1, 4).ToString(), out intervention); v.AddIntervention(intervention); v.IsDisponible = true; v.Km += trajetAssocie.Distance; v.NTrajet = -1; v.Place = gestionFlotte.GetPlaceDisp(); }
public bool ChargerVehicules(JToken jToken) { jToken = jToken.First; bool erreur = false; int lastNVehicule = 0; int i = 0; while (jToken != null) { try { int nVehicule = int.Parse(jToken["nVehicule"].ToString()); string marque = jToken["marque"].ToString(); string modele = jToken["modele"].ToString(); int km = int.Parse(jToken["km"].ToString()); string couleur = jToken["couleur"].ToString(); bool isDisponible = bool.Parse(jToken["isDisponible"].ToString()); string parking = jToken["parking"].ToString(); string strPlace = jToken["place"].ToString(); Place place; if (strPlace == "null") { place = null; } else { place = gestionFlotte.ParkingList.FindLast(p => p.Nom == parking).Places[int.Parse(strPlace.Substring(1))]; } JToken subtJToken = jToken["interventionList"].First; List <Intervention> interventionList = new List <Intervention>(); while (subtJToken != null) { Intervention interv; Intervention.TryParse(subtJToken["intervention"].ToString(), out interv); interventionList.Add(interv); subtJToken = subtJToken.Next; } int nTrajet = int.Parse(jToken["nTrajet"].ToString()); string vehiculeT = jToken["vehicule"].ToString(); if (vehiculeT.ToUpper() == "VOITURE") { int nbPortes = int.Parse(jToken["nbPortes"].ToString()); int puissance = int.Parse(jToken["puissance"].ToString()); TypeVoiture type; TypeVoiture.TryParse(jToken["type"].ToString(), out type); gestionFlotte.VehiculeList.Add(new Voiture(nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet, nbPortes, puissance, type)); } else if (vehiculeT.ToUpper() == "MOTO") { int cylindre = int.Parse(jToken["cylindre"].ToString()); gestionFlotte.VehiculeList.Add(new Moto(nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet, cylindre)); } else if (vehiculeT.ToUpper() == "CAMION") { int capacite = int.Parse(jToken["capacite"].ToString()); gestionFlotte.VehiculeList.Add(new Moto(nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet, capacite)); } if (lastNVehicule < nVehicule) { lastNVehicule = nVehicule; } } catch (Exception e) { erreur = true; } jToken = jToken.Next; } Vehicule.LastNVehicule = lastNVehicule; return(erreur); }