コード例 #1
0
 public static void ChangerTailleMinimum(RollerCoaster r, float tailleMinimum) //Changement d'une variable donnée
 {
     r.tailleMinimum = tailleMinimum;
 }
コード例 #2
0
        public static void CSVToAdmin(List <string[]> data) //Lecture du fichier CSV, instanciation des éléments et rangement dans leurs listes correspondantes
        {
            listeAttractions = new SortableBindingList <Attraction>();
            listePersonnel   = new SortableBindingList <Personnel>();

            List <Boutique>      listeBoutique      = new List <Boutique>();
            List <DarkRide>      listeDarkRide      = new List <DarkRide>();
            List <RollerCoaster> listeRollerCoaster = new List <RollerCoaster>();
            List <Spectacle>     listeSpectacle     = new List <Spectacle>();
            List <Sorcier>       listeSorcier       = new List <Sorcier>();
            List <Monstre>       listeMonstre       = new List <Monstre>();
            List <Demon>         listeDemon         = new List <Demon>();
            List <Fantome>       listeFantome       = new List <Fantome>();
            List <LoupGarou>     listeLoupGarou     = new List <LoupGarou>();
            List <Vampire>       listeVampire       = new List <Vampire>();
            List <Zombie>        listeZombie        = new List <Zombie>();

            List <Monstre> listNeant = new List <Monstre>();
            AttractionNull neant     = new AttractionNull(listNeant);

            neant.Nom = "néant";//Affectée à tous les monstres sans attraction
            listeAttractions.Add(neant);

            for (int i = 0; i < data.Count; i++)
            {
                if (data[i][0] == "Boutique")
                {
                    TypeBoutique type;
                    bool         besoinSpecifique;
                    if (data[i][6] == "souvenir")
                    {
                        type = TypeBoutique.souvenir;
                    }
                    else if (data[i][6] == "barbeAPapa")
                    {
                        type = TypeBoutique.barbeAPapa;
                    }
                    else
                    {
                        type = TypeBoutique.nourriture;
                    }
                    if (data[i][4] == "false" || data[i][4] == "False")
                    {
                        besoinSpecifique = false;
                    }
                    else
                    {
                        besoinSpecifique = true;
                    }
                    List <Monstre> Equipe       = new List <Monstre>();
                    int            ID           = int.Parse(data[i][1]);
                    int            nbMinMonstre = int.Parse(data[i][3]);
                    string         nom          = data[i][2];
                    string         typeBesoin   = data[i][5];
                    Boutique       boutique     = new Boutique(type, besoinSpecifique, Equipe, ID, nbMinMonstre, nom, typeBesoin);
                    listeBoutique.Add(boutique);
                }

                if (data[i][0] == "DarkRide")
                {
                    int    ID        = int.Parse(data[i][1]);
                    string nom       = data[i][2];
                    int    nbMonstre = int.Parse(data[i][3]);
                    bool   besoinSpecifique;
                    if (data[i][4] == "false" || data[i][4] == "False")
                    {
                        besoinSpecifique = false;
                    }
                    else
                    {
                        besoinSpecifique = true;
                    }
                    string   typeBesoin = data[i][5];
                    TimeSpan duree      = TimeSpan.Parse(data[i][6]);
                    bool     vehicule;
                    if (data[i][6] == "false" || data[i][6] == "False")
                    {
                        vehicule = false;
                    }
                    else
                    {
                        vehicule = true;
                    }
                    List <Monstre> Equipe   = new List <Monstre>();
                    DarkRide       darkRide = new DarkRide(duree, vehicule, besoinSpecifique, Equipe, ID, nbMonstre, nom, typeBesoin);
                    listeDarkRide.Add(darkRide);
                }
                if (data[i][0] == "RollerCoaster")
                {
                    int           ageMinimum = int.Parse(data[i][7]);
                    TypeCategorie type;
                    bool          besoinSpecifique;
                    if (data[i][6] == "assise")
                    {
                        type = TypeCategorie.assise;
                    }
                    else if (data[i][6] == "inversee")
                    {
                        type = TypeCategorie.inversee;
                    }
                    else
                    {
                        type = TypeCategorie.bobsleigh;
                    }
                    float tailleMinimum = float.Parse(data[i][8]);
                    if (data[i][4] == "false" || data[i][4] == "False")
                    {
                        besoinSpecifique = false;
                    }
                    else
                    {
                        besoinSpecifique = true;
                    }
                    List <Monstre> Equipe        = new List <Monstre>();
                    int            ID            = int.Parse(data[i][1]);
                    int            nbMinMonstre  = int.Parse(data[i][3]);
                    string         nom           = data[i][2];
                    string         typeBesoin    = data[i][5];
                    RollerCoaster  rollerCoaster = new RollerCoaster(ageMinimum, type, tailleMinimum, besoinSpecifique, Equipe, ID, nbMinMonstre, nom, typeBesoin);
                    listeRollerCoaster.Add(rollerCoaster);
                }
                if (data[i][0] == "Spectacle")
                {
                    List <DateTime> horaires    = new List <DateTime>();
                    string          horaire     = data[i][8];
                    string[]        tabHoraires = horaire.Split(' ');
                    int             count       = tabHoraires.Length;
                    //int countChar = tabHoraires[count-1].Length;
                    if (tabHoraires[count - 1] == "")
                    {
                        string[] tempTab = new string[count - 2];
                        for (int j = 0; j < tempTab.Length; j++)
                        {
                            tempTab[j] = tabHoraires[j];
                        }
                        tabHoraires = tempTab;
                    }
                    foreach (var substring in tabHoraires)
                    {
                        DateTime dateTime = DateTime.ParseExact(substring, "HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                        horaires.Add(dateTime);
                    }
                    int    nbPlaces = int.Parse(data[i][7]);
                    string nomSalle = data[i][6];
                    bool   besoinSpecifique;
                    if (data[i][4] == "false" || data[i][4] == "False")
                    {
                        besoinSpecifique = false;
                    }
                    else
                    {
                        besoinSpecifique = true;
                    }
                    List <Monstre> Equipe       = new List <Monstre>();
                    int            ID           = int.Parse(data[i][1]);
                    int            nbMinMonstre = int.Parse(data[i][3]);
                    string         nom          = data[i][2];
                    string         typeBesoin   = data[i][5];
                    Spectacle      spectacle    = new Spectacle(horaires, nbPlaces, nomSalle, besoinSpecifique, Equipe, ID, nbMinMonstre, nom, typeBesoin);
                    listeSpectacle.Add(spectacle);
                }
            }

            listeBoutique.ForEach(listeAttractions.Add);
            listeDarkRide.ForEach(listeAttractions.Add);
            listeRollerCoaster.ForEach(listeAttractions.Add);
            listeSpectacle.ForEach(listeAttractions.Add);

            for (int i = 0; i < data.Count; i++)
            {
                if (data[i][0] == "Sorcier")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string fonction = data[i][5];
                    Grade  grade;
                    if (data[i][6] == "novice")
                    {
                        grade = Grade.novice;
                    }
                    else if (data[i][4] == "mega")
                    {
                        grade = Grade.mega;
                    }
                    else if (data[i][6] == "giga")
                    {
                        grade = Grade.giga;
                    }
                    else
                    {
                        grade = Grade.strata;
                    }
                    List <string> pouvoirs    = new List <string>();
                    string        pouvoir     = data[i][7];
                    string[]      tabPouvoirs = pouvoir.Split('-');
                    foreach (var substring in tabPouvoirs)
                    {
                        pouvoirs.Add(substring);
                    }
                    Sorcier sorcier = new Sorcier(pouvoirs, grade, matricule, nom, prenom, type, fonction);
                    listeSorcier.Add(sorcier);
                }
                if (data[i][0] == "Monstre")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string     fonction = data[i][5];
                    int        cagnotte = int.Parse(data[i][6]);
                    Attraction attractionTemp;
                    if (data[i][7] != null && data[i][7] != "neant" && data[i][7] != "parc" && data[i][7] != "" && data[i][7] != "0")
                    {
                        string attract    = data[i][7];
                        int    attraction = int.Parse(attract);
                        bool   flag       = false;
                        foreach (var substring in listeAttractions)
                        {
                            if (substring.identifiant == attraction)
                            {
                                attractionTemp = substring;
                                Monstre monstre = new Monstre(true, attractionTemp, cagnotte, matricule, nom, prenom, type, fonction);
                                listeMonstre.Add(monstre);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Monstre monstre = new Monstre(true, neant, cagnotte, matricule, nom, prenom, type, fonction);
                            listeMonstre.Add(monstre);
                        }
                    }
                    else
                    {
                        Monstre monstre = new Monstre(true, neant, cagnotte, matricule, nom, prenom, type, fonction);
                        listeMonstre.Add(monstre);
                    }
                }
                if (data[i][0] == "Demon")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string     fonction = data[i][5];
                    int        cagnotte = int.Parse(data[i][6]);
                    int        force    = int.Parse(data[i][8]);
                    Attraction attractionTemp;
                    if (data[i][7] != null && data[i][7] != "neant" && data[i][7] != "parc" && data[i][7] != "" && data[i][7] != "0")
                    {
                        int  attraction = int.Parse(data[i][7]);
                        bool flag       = false;
                        foreach (var substring in listeAttractions)
                        {
                            if (substring.identifiant == attraction)
                            {
                                attractionTemp = substring;
                                Demon demon = new Demon(force, attractionTemp, cagnotte, matricule, nom, prenom, type, fonction);
                                listeDemon.Add(demon);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Demon demon = new Demon(force, neant, cagnotte, matricule, nom, prenom, type, fonction);
                            listeDemon.Add(demon);
                        }
                    }
                    else
                    {
                        Demon demon = new Demon(force, neant, cagnotte, matricule, nom, prenom, type, fonction);
                        listeDemon.Add(demon);
                    }
                }
                if (data[i][0] == "Fantome")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string     fonction = data[i][5];
                    int        cagnotte = int.Parse(data[i][6]);
                    Attraction attractionTemp;
                    if (data[i][7] != null && data[i][7] != "neant" && data[i][7] != "parc" && data[i][7] != "" && data[i][7] != "0")
                    {
                        int  attraction = int.Parse(data[i][7]);
                        bool flag       = false;
                        foreach (var substring in listeAttractions)
                        {
                            if (substring.identifiant == attraction)
                            {
                                attractionTemp = substring;
                                Fantome fantome = new Fantome(attractionTemp, cagnotte, matricule, nom, prenom, type, fonction);
                                listeFantome.Add(fantome);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Fantome fantome = new Fantome(neant, cagnotte, matricule, nom, prenom, type, fonction);
                            listeFantome.Add(fantome);
                        }
                    }
                    else
                    {
                        Fantome fantome = new Fantome(neant, cagnotte, matricule, nom, prenom, type, fonction);
                        listeFantome.Add(fantome);
                    }
                }
                if (data[i][0] == "LoupGarou")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string     fonction = data[i][5];
                    int        cagnotte = int.Parse(data[i][6]);
                    Attraction attractionTemp;
                    double     indiceCruaute = double.Parse(data[i][8]);
                    if (data[i][7] != null && data[i][7] != "neant" && data[i][7] != "parc" && data[i][7] != "" && data[i][7] != "0")
                    {
                        int  attraction = int.Parse(data[i][7]);
                        bool flag       = false;
                        foreach (var substring in listeAttractions)
                        {
                            if (substring.identifiant == attraction)
                            {
                                attractionTemp = substring;
                                LoupGarou loup = new LoupGarou(indiceCruaute, attractionTemp, cagnotte, matricule, nom, prenom, type, fonction);
                                listeLoupGarou.Add(loup);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            LoupGarou loup = new LoupGarou(indiceCruaute, neant, cagnotte, matricule, nom, prenom, type, fonction);
                            listeLoupGarou.Add(loup);
                        }
                    }
                    else
                    {
                        LoupGarou loup = new LoupGarou(indiceCruaute, neant, cagnotte, matricule, nom, prenom, type, fonction);
                        listeLoupGarou.Add(loup);
                    }
                }
                if (data[i][0] == "Zombie")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string     fonction = data[i][5];
                    int        cagnotte = int.Parse(data[i][6]);
                    Attraction attractionTemp; CouleurZ couleur; int degreDecomposition = int.Parse(data[i][9]);
                    if (data[i][8] == "grisatre")
                    {
                        couleur = CouleurZ.grisatre;
                    }
                    else
                    {
                        couleur = CouleurZ.bleuatre;
                    }
                    if (data[i][7] != null && data[i][7] != "neant" && data[i][7] != "parc" && data[i][7] != "" && data[i][7] != "0")
                    {
                        int  attraction = int.Parse(data[i][7]);
                        bool flag       = false;
                        foreach (var substring in listeAttractions)
                        {
                            if (substring.identifiant == attraction)
                            {
                                attractionTemp = substring;
                                Zombie zombie = new Zombie(degreDecomposition, couleur, attractionTemp, cagnotte, matricule, nom, prenom, type, fonction);
                                listeZombie.Add(zombie);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Zombie zombie = new Zombie(degreDecomposition, couleur, neant, cagnotte, matricule, nom, prenom, type, fonction);
                            listeZombie.Add(zombie);
                        }
                    }
                    else
                    {
                        Zombie zombie = new Zombie(degreDecomposition, couleur, neant, cagnotte, matricule, nom, prenom, type, fonction);
                        listeZombie.Add(zombie);
                    }
                }
                if (data[i][0] == "Vampire")
                {
                    int      matricule = int.Parse(data[i][1]);
                    string   nom       = data[i][2];
                    string   prenom    = data[i][3];
                    TypeSexe type;
                    if (data[i][4] == "femelle")
                    {
                        type = TypeSexe.femelle;
                    }
                    else if (data[i][4] == "male")
                    {
                        type = TypeSexe.male;
                    }
                    else
                    {
                        type = TypeSexe.autre;
                    }
                    string     fonction = data[i][5];
                    int        cagnotte = int.Parse(data[i][6]);
                    Attraction attractionTemp;
                    double     indiceLum = double.Parse(data[i][8]);
                    if (data[i][7] != null && data[i][7] != "neant" && data[i][7] != "parc" && data[i][7] != "" && data[i][7] != "0")
                    {
                        int  attraction = int.Parse(data[i][7]);
                        bool flag       = false;
                        foreach (var substring in listeAttractions)
                        {
                            if (substring.identifiant == attraction)
                            {
                                attractionTemp = substring;
                                Vampire vampire = new Vampire(indiceLum, attractionTemp, cagnotte, matricule, nom, prenom, type, fonction);
                                listeVampire.Add(vampire);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Vampire vampire = new Vampire(indiceLum, neant, cagnotte, matricule, nom, prenom, type, fonction);
                            listeVampire.Add(vampire);
                        }
                    }
                    else
                    {
                        Vampire vampire = new Vampire(indiceLum, neant, cagnotte, matricule, nom, prenom, type, fonction);
                        listeVampire.Add(vampire);
                    }
                }
            }

            Console.WriteLine(data.Count + " éléments ajoutés:");
            //Ajout des types particuliers à la liste globale "personnel".
            listeSorcier.ForEach(listePersonnel.Add);
            listeMonstre.ForEach(listePersonnel.Add);
            listeDemon.ForEach(listePersonnel.Add);
            listeFantome.ForEach(listePersonnel.Add);
            listeLoupGarou.ForEach(listePersonnel.Add);
            listeVampire.ForEach(listePersonnel.Add);
            listeZombie.ForEach(listePersonnel.Add);

            foreach (var substring in listeAttractions)
            {
                Console.WriteLine(substring.identifiant + " " + substring.nom + " " + substring.GetType());
            }
            foreach (var substring in listePersonnel)
            {
                Console.WriteLine(substring.matricule + " " + substring.nom + " " + substring.prenom + " " + substring.sexe + " " + substring.fonction + " " + substring.GetType());
            }
        }
コード例 #3
0
 public static void ChangerAgeMinimum(RollerCoaster r, int ageMinimum) //Changement d'une variable donnée
 {
     r.ageMinimum = ageMinimum;
 }