Beispiel #1
0
        static void RecuperationInfoPersonnel(string nomFichier)
        {
            List <Personnel>     maListe              = new List <Personnel>();
            List <Sorcier>       maListeSorcier       = new List <Sorcier>();
            List <Monstre>       maListeMonstre       = new List <Monstre>();
            List <Demon>         maListeDemon         = new List <Demon>();
            List <Fantome>       maListeFantome       = new List <Fantome>();
            List <LoupGarou>     maListeLoup          = new List <LoupGarou>();
            List <Vampire>       maListeVampire       = new List <Vampire>();
            List <Zombie>        maListeZombie        = new List <Zombie>();
            List <Attraction>    maListeAttraction    = new List <Attraction>();
            List <Boutique>      maListeBoutique      = new List <Boutique>();
            List <DarkRide>      maListeDarkRide      = new List <DarkRide>();
            List <RollerCoaster> maListeRollerCoaster = new List <RollerCoaster>();
            List <Spectacle>     maListeSpectacle     = new List <Spectacle>();

            //copier/coller du fichier disponible sur moodle
            StreamReader monStreamReader = new StreamReader(nomFichier); //ouvrir un fichier en flux d'entrée
            string       ligne           = monStreamReader.ReadLine();   //lire la première ligne du fichier


            while (ligne != null)                 //tant que la ligne lue n'est pas null --> encore des données
            {
                string[] temp = ligne.Split(';'); //Découper selon le séparateur ';' --> on obtient un tableau de chaine

                //MONSTRE
                TypeSexe sex = TypeSexe.male;               //par default male
                Enum.TryParse <TypeSexe>(temp[4], out sex); //car 4ieme indice du tab csv et modifie valeur sex par default

                //SORCIER
                Grade grade = Grade.novice;                //par default novice
                Enum.TryParse <Grade>(temp[6], out grade); //6ieme indice et modifie val grade par default

                //ZOMBIE
                couleurZ couleur = couleurZ.bleuatre;           //par default bleuatre
                Enum.TryParse <couleurZ>(temp[8], out couleur); //8ieme indice et modifie val grade par default

                //BOUTIQUE
                TypeBoutique typeb = TypeBoutique.souvenir;
                Enum.TryParse <TypeBoutique>(temp[6], out typeb);

                //ROLLERCOASTER
                TypeCategorie categorie = TypeCategorie.bobsleigh;
                Enum.TryParse <TypeCategorie>(temp[6], out categorie);

                //DATETIME
                //DateTime myDate;
                //DateTime.TryParse(temp[8], out myDate);

                string[] tempL = ligne.Split('-');//Découper selon le séparateur '-' pour recuperer les pouvoirs dans une liste

                //Liste Horaires
                string[] tempH = ligne.Split(' ');//Découper selon le séparateur ' ' pour recuperer les horaires dans une liste
                tempH.ToList();
                // List<DateTime> time = tempH.Select(date => DateTime.Parse(date)).ToList();

                switch (temp[0])
                {
                case "Sorcier":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write("  " + val);
                    }
                    Sorcier sor = new Sorcier(temp[5], Convert.ToInt32(temp[1]), temp[2], temp[3], sex, grade, tempL.ToList());      //aller chercher la case 5 / .ToList transforme en liste
                                                                                                                                     //alimenter la liste de téléphone
                    maListe.Add(sor);
                    maListeSorcier.Add(sor);
                    break;

                case "Monstre":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    Monstre mon = new Monstre(temp[5], Int32.Parse(temp[1]), temp[2], temp[3], sex, Int32.Parse(temp[6]), temp[7]);    //trouver fonction qui trouve lattraction grace a l'identifiant
                                                                                                                                       //alimenter la liste de monstre
                    maListe.Add(mon);
                    maListeMonstre.Add(mon);
                    break;


                case "Demon":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    Demon dem = new Demon(temp[5], Int32.Parse(temp[1]), temp[2], temp[3], sex, Int32.Parse(temp[6]), temp[7], Int32.Parse(temp[8]), false);
                    maListe.Add(dem);
                    maListeDemon.Add(dem); break;

                case "Fantome":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    Fantome fant = new Fantome(temp[5], Int32.Parse(temp[1]), temp[2], temp[3], sex, Int32.Parse(temp[6]), temp[7]);
                    maListe.Add(fant);
                    maListeFantome.Add(fant); break;

                case "LoupGarou":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    LoupGarou lou = new LoupGarou(temp[5], Int32.Parse(temp[1]), temp[2], temp[3], sex, Int32.Parse(temp[6]), temp[7], Double.Parse(temp[8]));
                    maListe.Add(lou);
                    maListeLoup.Add(lou); break;

                case "Vampire":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    Vampire vam = new Vampire(temp[5], Int32.Parse(temp[1]), temp[2], temp[3], sex, Int32.Parse(temp[6]), temp[7], Double.Parse(temp[8]));
                    maListe.Add(vam);
                    maListeVampire.Add(vam); break;

                case "Zombie":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write("  " + val);
                    }

                    Zombie zom = new Zombie(temp[5], Int32.Parse(temp[1]), temp[2], temp[3], sex, Int32.Parse(temp[6]), temp[7], Int32.Parse(temp[9]), couleur, false);
                    maListe.Add(zom);
                    maListeZombie.Add(zom); break;

                case "Boutique":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    Boutique bou = new Boutique(temp[4], TimeSpan.Zero, null, Int32.Parse(temp[1]), false, temp[5], Int32.Parse(temp[3]), temp[2], true, temp[5], typeb);
                    maListeAttraction.Add(bou);
                    maListeBoutique.Add(bou); break;

                case "DarkRide":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    DarkRide dark = new DarkRide(temp[4], TimeSpan.Zero, null, Int32.Parse(temp[1]), false, temp[5], Int32.Parse(temp[3]), temp[2], true, temp[5], TimeSpan.Zero, true);
                    maListeAttraction.Add(dark);
                    maListeDarkRide.Add(dark); break;

                case "RollerCoaster":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }

                    RollerCoaster roll = new RollerCoaster(temp[4], TimeSpan.Zero, null, Int32.Parse(temp[1]), false, temp[5], Int32.Parse(temp[3]), temp[2], true, temp[5], Int32.Parse(temp[7]), categorie, float.Parse(temp[8]));
                    maListeAttraction.Add(roll);
                    maListeRollerCoaster.Add(roll); break;

                case "Spectacle":
                    Console.WriteLine();
                    foreach (string val in temp)
                    {
                        Console.Write(" " + val);
                    }
                    Spectacle spec = new Spectacle(temp[4], TimeSpan.Zero, null, Int32.Parse(temp[1]), false, "try", Int32.Parse(temp[3]), temp[2], true, temp[5], "00:00", Int32.Parse(temp[7]), temp[6]);
                    maListeAttraction.Add(spec);
                    maListeSpectacle.Add(spec); break;
                }
                ligne = monStreamReader.ReadLine();
            }
            monStreamReader.Close();
        }
Beispiel #2
0
 public Zombie(string fct, int mat, string n, string p, TypeSexe sexe, int cagn, string affect, int degreDeCompo, couleurZ teint, bool invisibilite) : base(fct, mat, n, p, sexe, cagn, affect)
 {
     this.degreDeComposition = degreDeCompo;
     this.teint        = teint;
     this.invisibilite = false;
 }