Ejemplo n.º 1
0
        private void Btn_Commander_Click(object sender, RoutedEventArgs e)
        {
            Pizza[] pizzas = new Pizza[compteurFrom + compteurChor + compteurVege];
            if (compteurFrom > 0 || compteurChor > 0 || compteurVege > 0)
            {
                Pizza pizzaFrom = new Pizza();
                Pizza pizzaChor = new Pizza();
                Pizza pizzaVege = new Pizza();
                if (PetiteFrom.IsChecked == true)
                {
                    pizzaFrom = new Pizza("petite", "4 fromages", petiteFrom);
                }
                if (MoyenneFrom.IsChecked == true)
                {
                    pizzaFrom = new Pizza("moyenne", "4 fromages", moyenneFrom);
                }
                if (GrandeFrom.IsChecked == true)
                {
                    pizzaFrom = new Pizza("grande", "4 fromages", grandeFrom);
                }

                if (PetiteChor.IsChecked == true)
                {
                    pizzaChor = new Pizza("petite", "chorizo", petiteChor);
                }
                if (MoyenneChor.IsChecked == true)
                {
                    pizzaChor = new Pizza("moyenne", "chorizo", moyenneChor);
                }
                if (GrandeChor.IsChecked == true)
                {
                    pizzaChor = new Pizza("grande", "chorizo", grandeChor);
                }

                if (PetiteVege.IsChecked == true)
                {
                    pizzaVege = new Pizza("petite", "végétarienne", petiteVege);
                }
                if (MoyenneVege.IsChecked == true)
                {
                    pizzaVege = new Pizza("moyenne", "végétarienne", moyenneVege);
                }
                if (GrandeVege.IsChecked == true)
                {
                    pizzaVege = new Pizza("grande", "végétarienne", grandeVege);
                }

                for (int i = 0; i < compteurFrom; i++)
                {
                    pizzas[i] = pizzaFrom;
                }
                for (int j = compteurFrom; j < compteurFrom + compteurChor; j++)
                {
                    pizzas[j] = pizzaChor;
                }
                for (int k = compteurFrom + compteurChor; k < compteurFrom + compteurChor + compteurVege; k++)
                {
                    pizzas[k] = pizzaVege;
                }
            }
            List <Boissons> boissons = new List <Boissons> {
            };

            if (compteurCoca > 0 || compteurJus > 0 || compteurIceTea > 0)
            {
                Boissons coca      = new Boissons();
                Boissons jusorange = new Boissons();
                Boissons icetea    = new Boissons();
                if (PetitCoca.IsChecked == true)
                {
                    coca = new Boissons("Coca", 33, coca33cl);
                }
                if (MoyenCoca.IsChecked == true)
                {
                    coca = new Boissons("Coca", 50, coca50cl);
                }
                if (GrandCoca.IsChecked == true)
                {
                    coca = new Boissons("Coca", 100, coca1l);
                }

                if (PetitOrange.IsChecked == true)
                {
                    jusorange = new Boissons("Jus d'orange", 33, jus33cl);
                }
                if (MoyenOrange.IsChecked == true)
                {
                    jusorange = new Boissons("Jus d'orange", 50, jus50cl);
                }
                if (GrandOrange.IsChecked == true)
                {
                    jusorange = new Boissons("Jus d'orange", 100, jus1l);
                }

                if (PetitIceTea.IsChecked == true)
                {
                    icetea = new Boissons("Ice Tea", 33, icetea33cl);
                }
                if (MoyenIceTea.IsChecked == true)
                {
                    icetea = new Boissons("Ice Tea", 50, icetea50cl);
                }
                if (GrandIceTea.IsChecked == true)
                {
                    icetea = new Boissons("Ice Tea", 100, icetea1l);
                }

                for (int i = 0; i < compteurCoca; i++)
                {
                    boissons.Add(coca);
                }
                for (int j = compteurCoca; j < compteurCoca + compteurJus; j++)
                {
                    boissons.Add(jusorange);
                }
                for (int k = compteurCoca + compteurJus; k < compteurCoca + compteurJus + compteurIceTea; k++)
                {
                    boissons.Add(icetea);
                }
            }
            bool dispo = false;

            foreach (Livreur livreur in livreurs)
            {
                if (livreur.Etat == "Sur place" || livreur.Etat == "surplace")
                {
                    dispo = true;
                }
            }
            bool pizzaobli = false;

            if (compteurFrom + compteurChor + compteurVege > 0)
            {
                pizzaobli = true;
            }
            if (dispo == true && pizzaobli == true)
            {
                Commande commande = new Commande(pizzas, compteurPrixFrom + compteurPrixChor + compteurPrixVege + compteurPrixCoca + compteurPrixJus + compteurPrixIceTea, this.client.NumTel, boissons);

                this.client.Commandes.Add(commande);
                this.client.AchatsCumulés += commande.Prix;
                main.GoBackToStartPageCommander(commande);
            }
            else
            {
                if (dispo == false)
                {
                    MessageBox.Show("Navré, aucun livreur n'est pour l'instant disponible : ajoutez un nouveau livreur, où attendez qu'un livreur finisse sa livraison !");
                }
                if (pizzaobli == false)
                {
                    MessageBox.Show("Une commande doit comporter au moins une pizza");
                }
            }
        }
Ejemplo n.º 2
0
        public override string ToString()
        {
            string str = "";

            int compteurFrom = 0;
            int compteurChor = 0;
            int compteurVege = 0;

            int compteurCoca      = 0;
            int compteurJusOrange = 0;
            int compteurIceTea    = 0;

            Pizza pizzaFrom = new Pizza();
            Pizza pizzaChor = new Pizza();
            Pizza pizzaVege = new Pizza();

            Boissons coca      = new Boissons();
            Boissons jusOrange = new Boissons();
            Boissons iceTea    = new Boissons();

            foreach (Pizza piz in this.pizzas)
            {
                if (piz.Type == "4 fromages")
                {
                    compteurFrom++; pizzaFrom = piz;
                }
                if (piz.Type == "chorizo")
                {
                    compteurChor++; pizzaChor = piz;
                }
                if (piz.Type == "végétarienne")
                {
                    compteurVege++; pizzaVege = piz;
                }
            }

            foreach (Boissons bois in this.boissons)
            {
                if (bois.Nom == "Coca")
                {
                    compteurCoca++; coca = bois;
                }
                if (bois.Nom == "Jus d'orange")
                {
                    compteurJusOrange++; jusOrange = bois;
                }
                if (bois.Nom == "Ice Tea")
                {
                    compteurIceTea++; iceTea = bois;
                }
            }

            if (compteurFrom > 0)
            {
                str += "\n" + compteurFrom + " * " + pizzaFrom.ToString();
            }
            if (compteurChor > 0)
            {
                str += "\n" + compteurChor + " * " + pizzaChor.ToString();
            }
            if (compteurVege > 0)
            {
                str += "\n" + compteurVege + " * " + pizzaVege.ToString();
            }

            if (compteurCoca > 0)
            {
                str += "\n" + compteurCoca + " * " + coca.ToString();
            }
            if (compteurJusOrange > 0)
            {
                str += "\n" + compteurJusOrange + " * " + jusOrange.ToString();
            }
            if (compteurIceTea > 0)
            {
                str += "\n" + compteurIceTea + " * " + iceTea.ToString();
            }

            return(str);
        }