using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; /*******************************************************/ /*******************************************************/ /* Logiciel crée par Milosevic Stefan & Jactel Vincent */ /*******************************************************/ /*******************************************************/ namespace VP { /********************************************************/ /* Class : Pour la classe Générique Vehicle */ /********************************************************/ [Serializable] abstract class Vehicle { private string type; private string nom; private string marque; private int prixDuVoyage; private bool isBooked; // Date de début et de fin du IsBooked private ArrayList DateTimeD = new ArrayList(); private ArrayList DateTimeF = new ArrayList(); /* Constructeur */ public Vehicle(string type, string nom, string marque, int prix, bool isB) { this.type = type; this.nom = nom; this.marque = marque; this.prixDuVoyage = prix; this.isBooked = isB; } /***********/ /* GETTERS */ /***********/ public string getType() { return this.type; } public string getNom() { return this.nom; } public string getMarque() { return this.marque; } public int getPrixVoyage() { return this.prixDuVoyage; } public bool getIsBooked() { return this.isBooked; } public ArrayList getArrayDateD() { return this.DateTimeD; } public ArrayList getArrayDateF() { return this.DateTimeF; } /* SETTERS */ public void setIsBooked(bool b, DateTime DateD, DateTime DateF) { this.isBooked = b; DateTimeD.Add(DateD); DateTimeF.Add(DateF); } // Méthode pour savoir si le véhicule est utilisé à une période donnée public bool estLibre(DateTime d, DateTime f) { bool dispo = true; int indexD = 0; int indexF = 0; foreach (DateTime dd in DateTimeD) { indexF = 0; foreach (DateTime ff in DateTimeF) { // On test si on est a la même position dans les deux Array (pour avoir les dates qui vont ensemble) if (indexD == indexF) { // Si c'est le cas : on test pour voir si les dates fournit par la personne // s'entrecroise avec celle des autres voyages if (((DateTime.Compare(ff, d) < 0)) || ((DateTime.Compare(dd, f) > 0))) { } else { // Alors on renvoie que le vehicule est utilisé dans cette periode de temps // on renvoie faux dispo = false; } } indexF++; } indexD++; } return dispo; } // Méthod To do in the daughter classes abstract public int CalculatePrice(); } }