Esempio n. 1
0
        private void BoutonConfirme_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem typeItem = (ComboBoxItem)Choix.SelectedItem;
            string       choix    = typeItem.Content.ToString();

            if (choix == "Sorcier")
            {
                int           mat           = Convert.ToInt32(Texte1.Text);
                string        nom           = Texte2.Text;
                string        prenom        = Texte3.Text;
                string        fonction      = Texte4.Text;
                List <string> listePouvoirs = new List <string>();
                string        temp          = "";
                foreach (char elt in Texte5.Text)
                {
                    if (elt != '-')
                    {
                        temp = temp + elt;
                    }
                    else
                    {
                        listePouvoirs.Add(temp);
                        temp = "";
                    }
                }
                listePouvoirs.Add(temp);
                string   sexeSelection  = (string)Liste8.SelectionBoxItem;
                typesexe sexe           = RecupererSexe(sexeSelection);
                string   gradeSelection = (string)Liste9.SelectionBoxItem;
                Grade    grade          = Grade.novice;
                switch (gradeSelection)
                {
                case ("Strata"):
                {
                    grade = Grade.strata;
                    break;
                }

                case ("Mega"):
                {
                    grade = Grade.mega;
                    break;
                }

                case ("Giga"):
                {
                    grade = Grade.giga;
                    break;
                }
                }
                Sorcier sorcier = new Sorcier(listePouvoirs, grade, fonction, mat, nom, prenom, sexe);
                admin.AjouterSorcier(sorcier);
                MessageBox.Show("Sorcier ajouté.");
            }
            if (choix == "Monstre")
            {
                int        mat        = Convert.ToInt32(Texte1.Text);
                string     nom        = Texte2.Text;
                string     prenom     = Texte3.Text;
                string     fonction   = Texte4.Text;
                int        cagnotte   = Convert.ToInt32(Texte5.Text);
                Attraction attraction = new Attraction();
                typesexe   sexe       = RecupererSexe((string)Liste8.SelectionBoxItem);
                Monstre    monstre    = new Monstre(attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterMonstre(monstre);
                MessageBox.Show("Monstre ajouté.");
            }
            if (choix == "Démon")
            {
                int        mat        = Convert.ToInt32(Texte1.Text);
                string     nom        = Texte2.Text;
                string     prenom     = Texte3.Text;
                string     fonction   = Texte4.Text;
                int        cagnotte   = Convert.ToInt32(Texte5.Text);
                int        force      = Convert.ToInt32(Texte7.Text);
                Attraction attraction = new Attraction();
                typesexe   sexe       = RecupererSexe((string)Liste8.SelectionBoxItem);
                Demon      demon      = new Demon(force, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterDemon(demon);
                MessageBox.Show("Démon ajouté.");
            }
            if (choix == "Fantôme")
            {
                int        mat        = Convert.ToInt32(Texte1.Text);
                string     nom        = Texte2.Text;
                string     prenom     = Texte3.Text;
                string     fonction   = Texte4.Text;
                int        cagnotte   = Convert.ToInt32(Texte5.Text);
                Attraction attraction = new Attraction();
                typesexe   sexe       = RecupererSexe((string)Liste8.SelectionBoxItem);
                Fantome    fantome    = new Fantome(attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterFantome(fantome);
                MessageBox.Show("Fantôme ajouté");
            }
            if (choix == "Loup Garou")
            {
                int        mat           = Convert.ToInt32(Texte1.Text);
                string     nom           = Texte2.Text;
                string     prenom        = Texte3.Text;
                string     fonction      = Texte4.Text;
                int        cagnotte      = Convert.ToInt32(Texte5.Text);
                double     indiceCruaute = Convert.ToDouble(Texte7.Text);
                Attraction attraction    = new Attraction();
                typesexe   sexe          = RecupererSexe((string)Liste8.SelectionBoxItem);
                LoupGarou  loupGarou     = new LoupGarou(indiceCruaute, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterLoupGarou(loupGarou);
                MessageBox.Show("Loup garou ajouté.");
            }
            if (choix == "Vampire")
            {
                int        mat              = Convert.ToInt32(Texte1.Text);
                string     nom              = Texte2.Text;
                string     prenom           = Texte3.Text;
                string     fonction         = Texte4.Text;
                int        cagnotte         = Convert.ToInt32(Texte5.Text);
                double     indiceLuminosite = Convert.ToDouble(Texte7.Text);
                Attraction attraction       = new Attraction();
                typesexe   sexe             = RecupererSexe((string)Liste8.SelectionBoxItem);
                Vampire    vampire          = new Vampire(indiceLuminosite, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterVampire(vampire);
                MessageBox.Show("Vampire ajouté.");
            }
            if (choix == "Zombie")
            {
                int        mat                = Convert.ToInt32(Texte1.Text);
                string     nom                = Texte2.Text;
                string     prenom             = Texte3.Text;
                string     fonction           = Texte4.Text;
                int        cagnotte           = Convert.ToInt32(Texte5.Text);
                int        degreDecomposition = Convert.ToInt32(Texte7.Text);
                Attraction attraction         = new Attraction();
                typesexe   sexe               = RecupererSexe((string)Liste8.SelectionBoxItem);
                CouleurZ   couleur            = CouleurZ.bleuatre;
                if ((string)Liste9.SelectionBoxItem == "grisatre")
                {
                    couleur = CouleurZ.grisatre;
                }
                Zombie zombie = new Zombie(degreDecomposition, couleur, attraction, cagnotte, fonction, mat, nom, prenom, sexe);
                admin.AjouterZombie(zombie);
                MessageBox.Show("Zombie ajouté.");
            }
            if (choix == "Boutique")
            {
                string       id               = Texte1.Text;
                string       nom              = Texte2.Text;
                int          nbMin            = Convert.ToInt32(Texte3.Text);
                string       typeBesoin       = Texte4.Text;
                bool         besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                TypeBoutique typeBoutique     = TypeBoutique.barbeAPapa;
                switch ((string)Liste9.SelectionBoxItem)
                {
                case ("Souvenir"):
                {
                    typeBoutique = TypeBoutique.souvenir;
                    break;
                }

                case ("Nourriture"):
                {
                    typeBoutique = TypeBoutique.nourriture;
                    break;
                }
                }
                List <Monstre> equipe   = new List <Monstre>();
                TimeSpan       time     = new TimeSpan(0);
                Boutique       boutique = new Boutique(typeBoutique, besoinSpecifique, time, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                MessageBox.Show("Boutique ajoutée.");
            }
            if (choix == "DarkRide")
            {
                string         id               = Texte1.Text;
                string         nom              = Texte2.Text;
                int            nbMin            = Convert.ToInt32(Texte3.Text);
                string         typeBesoin       = Texte4.Text;
                TimeSpan       time             = new TimeSpan(0, Convert.ToInt32(Texte5.Text), 0);
                bool           besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                bool           vehicule         = RecupererBool((string)Liste9.SelectionBoxItem);
                TimeSpan       dureeMaintenance = new TimeSpan(0);
                List <Monstre> equipe           = new List <Monstre>();
                DarkRide       darkRide         = new DarkRide(time, vehicule, besoinSpecifique, dureeMaintenance, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                admin.AjouterDarkRide(darkRide);
                MessageBox.Show("DarkRide ajouté.");
            }
            if (choix == "RollerCoaster")
            {
                string        id               = Texte1.Text;
                string        nom              = Texte2.Text;
                int           nbMin            = Convert.ToInt32(Texte3.Text);
                string        typeBesoin       = Texte4.Text;
                int           ageMin           = Convert.ToInt32(Texte5.Text);
                int           tailleMin        = Convert.ToInt32(Texte6.Text);
                bool          besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                TypeCategorie typeCategorie    = TypeCategorie.assise;
                switch ((string)Liste9.SelectionBoxItem)
                {
                case ("Bobsleigh"):
                {
                    typeCategorie = TypeCategorie.bobsleigh;
                    break;
                }

                case ("Inversée"):
                {
                    typeCategorie = TypeCategorie.inversee;
                    break;
                }
                }
                TimeSpan       dureeMaintenance = new TimeSpan(0);
                List <Monstre> equipe           = new List <Monstre>();
                RollerCoaster  roller           = new RollerCoaster(ageMin, typeCategorie, tailleMin, besoinSpecifique, dureeMaintenance, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                admin.AjouterRollerCoaster(roller);
                MessageBox.Show("RollerCoaster ajouté.");
            }
            if (choix == "Spectacle")
            {
                string          id           = Texte1.Text;
                string          nom          = Texte2.Text;
                int             nbMin        = Convert.ToInt32(Texte3.Text);
                string          typeBesoin   = Texte4.Text;
                string          nomSalle     = Texte5.Text;
                int             nbPlaces     = Convert.ToInt32(Texte6.Text);
                List <DateTime> listeHoraire = new List <DateTime>();
                string[]        lHoraire     = Texte7.Text.Split(' ');
                foreach (string elt in lHoraire)
                {
                    listeHoraire.Add(Convert.ToDateTime(elt));
                }
                bool           besoinSpecifique = RecupererBool((string)Liste8.SelectionBoxItem);
                TimeSpan       dureeMaintenance = new TimeSpan(0);
                List <Monstre> equipe           = new List <Monstre>();
                Spectacles     spectacles       = new Spectacles(listeHoraire, nbPlaces, nomSalle, besoinSpecifique, dureeMaintenance, equipe, id, false, "", nbMin, nom, true, typeBesoin);
                admin.AjouterSpectacle(spectacles);
                MessageBox.Show("Spectacle ajouté.");
            }
        }
Esempio n. 2
0
 public void AjouterBoutique(Boutique boutique)
 {
     this.listeBoutiques.Add(boutique);
     this.attractions.Add(boutique);
 }
Esempio n. 3
0
        static public void LireFichierAttraction(StreamReader fichier, Administration admin, TextBlock text)
        {
            string ligne = fichier.ReadLine();

            while (ligne != null)
            {
                string[] temp = ligne.Split(';');
                if (temp[0] == "Boutique")
                {
                    try
                    {
                        string test = temp[6];
                        string identifiantBoutique  = temp[1];
                        string nomBoutique          = temp[2];
                        int    nbMinMonstreBoutique = 0;
                        try
                        {
                            nbMinMonstreBoutique = Convert.ToInt32(temp[3]);
                        }
                        catch (Exception ex)
                        {
                        }
                        bool besoinSpecifiqueBoutique = false;
                        try
                        {
                            besoinSpecifiqueBoutique = Convert.ToBoolean(temp[4]);
                        }
                        catch (Exception ex)
                        {
                        }
                        string       typeDeBesoinBoutique = temp[5];
                        TypeBoutique type = TypeBoutique.souvenir;
                        if (temp[6] == "barbeAPapa")
                        {
                            type = TypeBoutique.barbeAPapa;
                        }
                        if (temp[6] == "nourriture")
                        {
                            type = TypeBoutique.nourriture;
                        }
                        List <Monstre> EquipeBoutique            = new List <Monstre>();
                        TimeSpan       dureeMaintenanceBoutique  = new TimeSpan(0, 0, 0, 0);
                        bool           maintenanceBoutique       = false;
                        string         natureMaintenanceBoutique = "";
                        bool           ouvertBoutique            = true;
                        Boutique       boutique = new Boutique(type, besoinSpecifiqueBoutique, dureeMaintenanceBoutique, EquipeBoutique, identifiantBoutique, maintenanceBoutique, natureMaintenanceBoutique, nbMinMonstreBoutique, nomBoutique, ouvertBoutique, typeDeBesoinBoutique);
                        admin.AjouterBoutique(boutique);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (temp[0] == "DarkRide")
                {
                    try
                    {
                        string test = temp[7];
                        string identifiantDarkRide  = temp[1];
                        string nomDarkRide          = temp[2];
                        int    nbMinMonstreDarkRide = 0;
                        try
                        {
                            nbMinMonstreDarkRide = Convert.ToInt32(temp[3]);
                        }
                        catch (Exception ex)
                        {
                        }
                        bool besoinSpecifiqueDarkRide = false;
                        try
                        {
                            besoinSpecifiqueDarkRide = Convert.ToBoolean(temp[4]);
                        }
                        catch (Exception ex)
                        {
                        }
                        string   typeDeBesoinDarkRide = temp[5];
                        TimeSpan dureeDarkRide        = new TimeSpan(0, 0, Convert.ToInt32(temp[6]), 0);
                        bool     vehiculeDarkRide     = false;
                        try
                        {
                            vehiculeDarkRide = Convert.ToBoolean(temp[7]);
                        }
                        catch (Exception ex)
                        {
                        }
                        List <Monstre> EquipeDarkRide            = new List <Monstre>();
                        TimeSpan       dureeMaintenanceDarkRide  = new TimeSpan(0, 0, 0, 0);
                        bool           maintenanceDarkRide       = false;
                        string         natureMaintenanceDarkRide = "";
                        bool           ouvertDarkRide            = true;
                        DarkRide       darkRide = new DarkRide(dureeDarkRide, vehiculeDarkRide, besoinSpecifiqueDarkRide, dureeMaintenanceDarkRide, EquipeDarkRide, identifiantDarkRide, maintenanceDarkRide, natureMaintenanceDarkRide, nbMinMonstreDarkRide, nomDarkRide, ouvertDarkRide, typeDeBesoinDarkRide);
                        admin.AjouterDarkRide(darkRide);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (temp[0] == "RollerCoaster")
                {
                    try
                    {
                        string test = temp[8];
                        string identifiantRollerCoaster  = temp[1];
                        string nomRollerCoaster          = temp[2];
                        int    nbMinMonstreRollerCoaster = 0;
                        try
                        {
                            nbMinMonstreRollerCoaster = Convert.ToInt32(temp[3]);
                        }
                        catch (Exception ex)
                        {
                        }
                        bool besoinSpecifiqueRollerCoaster = false;
                        try
                        {
                            besoinSpecifiqueRollerCoaster = Convert.ToBoolean(temp[4]);
                        }
                        catch (Exception ex)
                        {
                        }
                        string        typeDeBesoinRollerCoaster = temp[5];
                        TypeCategorie categorieRollerCoaster    = TypeCategorie.assise;
                        if (temp[6] == "bobsleigh")
                        {
                            categorieRollerCoaster = TypeCategorie.bobsleigh;
                        }
                        if (temp[6] == "inversee")
                        {
                            categorieRollerCoaster = TypeCategorie.inversee;
                        }
                        int ageMinimumRollerCoaster = 0;
                        try
                        {
                            ageMinimumRollerCoaster = Convert.ToInt32(temp[7]);
                        }
                        catch (Exception ex)
                        {
                        }
                        double tailleMinimumRollerCoaster = 0;
                        try
                        {
                            tailleMinimumRollerCoaster = Convert.ToDouble(temp[8]);
                        }
                        catch (Exception ex)
                        {
                        }
                        List <Monstre> EquipeRollerCoaster            = new List <Monstre>();
                        TimeSpan       dureeMaintenanceRollerCoaster  = new TimeSpan(0, 0, 0, 0);
                        bool           maintenanceRollerCoaster       = false;
                        string         natureMaintenanceRollerCoaster = "";
                        bool           ouvertRollerCoaster            = true;
                        RollerCoaster  rollerCoaster = new RollerCoaster(ageMinimumRollerCoaster, categorieRollerCoaster, tailleMinimumRollerCoaster, besoinSpecifiqueRollerCoaster, dureeMaintenanceRollerCoaster, EquipeRollerCoaster, identifiantRollerCoaster, maintenanceRollerCoaster, natureMaintenanceRollerCoaster, nbMinMonstreRollerCoaster, nomRollerCoaster, ouvertRollerCoaster, typeDeBesoinRollerCoaster);
                        admin.AjouterRollerCoaster(rollerCoaster);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (temp[0] == "Spectacle")
                {
                    try
                    {
                        string test = temp[8];
                        string identifiantSpectacle  = temp[1];
                        string nomSpectacle          = temp[2];
                        int    nbMinMonstreSpectacle = 0;
                        try
                        {
                            nbMinMonstreSpectacle = Convert.ToInt32(temp[3]);
                        }
                        catch (Exception ex)
                        {
                        }
                        bool besoinSpecifiqueSpectacle = false;
                        try
                        {
                            besoinSpecifiqueSpectacle = Convert.ToBoolean(temp[4]);
                        }
                        catch (Exception ex)
                        {
                        }
                        string typeDeBesoinSpectacle = temp[5];
                        string nomSalleSpectacle     = temp[6];
                        int    nbPlaceSpectacle      = 0;
                        try
                        {
                            nbPlaceSpectacle = Convert.ToInt32(temp[7]);
                        }
                        catch (Exception ex)
                        {
                        }
                        List <DateTime> horaireSpectacle = new List <DateTime>();
                        string[]        tempDate         = temp[8].Split(' ');
                        foreach (string elt in tempDate)
                        {
                            horaireSpectacle.Add(Convert.ToDateTime(elt));
                        }
                        List <Monstre> EquipeSpectacle            = new List <Monstre>();
                        TimeSpan       dureeMaintenanceSpectacle  = new TimeSpan(0, 0, 0, 0);
                        bool           maintenanceSpectacle       = false;
                        string         natureMaintenanceSpectacle = "";
                        bool           ouvertSpectacle            = true;
                        Spectacles     spectacle = new Spectacles(horaireSpectacle, nbPlaceSpectacle, nomSalleSpectacle, besoinSpecifiqueSpectacle, dureeMaintenanceSpectacle, EquipeSpectacle, identifiantSpectacle, maintenanceSpectacle, natureMaintenanceSpectacle, nbMinMonstreSpectacle, nomSpectacle, ouvertSpectacle, typeDeBesoinSpectacle);
                        admin.AjouterSpectacle(spectacle);
                        text.Text = text.Text + "\n" + ligne;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                ligne = fichier.ReadLine();
            }
            fichier.Close();
        }