Наследование: ScriptableObject
        static void Main(string[] args)
        {
            var produce = new List<object>();

            var f1 = new Fruit("Apple",8.5,3);
           // f1.Name = "Apple";
           // f1.Weight = 4.6;
           // f1.Quantity = 3;
            produce.Add(f1);

            var f2 = new Vegetable();
            f2.Name = "Bananna";
            f2.Weight = 4.9;
            f2.Quantity = 7;
            produce.Add(f2);

            produce.Add(new Vegetable());
            ((Vegetable)produce[2]).Name = "Carrot";
            ((Vegetable)produce[2]).Weight = 9.6;
            ((Vegetable)produce[2]).Quantity = 14;

            Console.WriteLine("There are "+produce.Count+" items");

            foreach (var item in produce)
            {
                Console.WriteLine(item);
            }

        }
Пример #2
0
 /// <summary>
 /// Puts the vegetable in the <see cref="Kitchen.Utensil"/>.
 /// </summary>
 /// <param name="vegetable">The vegetable.</param>
 /// <returns>The result of the action.</returns>
 public string Add(Vegetable vegetable)
 {
     return string.Format(
         "Put the {0} in the {1}.\r\n" +
         "(\"Double, double toil and trouble;\r\nFire burn, and cauldron bubble.\")",
         vegetable,
         this);
 }
Пример #3
0
        private void Cut(Vegetable vegetable)
        {
            if (vegetable == null)
            {
                throw new ArgumentNullException("Vegetable cannot be null");
            }

            vegetable.IsCut = true;
        }
Пример #4
0
 public void Add(Vegetable vegetable)
 {
     if (vegetable.IsPeeled && vegetable.IsCut)
     {
         this.Content.Add(vegetable);
     }
     else
     {
         throw new ArgumentException("The vegetable shoud be peeled and cut.");
     }
 }
Пример #5
0
    public void Cook(Vegetable vegetable)
    {
        vegetable = this.GetVegetable();

        this.Peel(vegetable);

        this.Cut(vegetable);

        Bowl bowl = this.GetBowl();
        bowl.BowlList.Add(vegetable);
    }
Пример #6
0
    // Methods
    public void Cook(Vegetable item)
    {
        this.Peel(item);
        this.Cut(item);

        // Creating bowl
        Bowl bowl = this.GetBowl();

        // Adding the peeled and cut vegies
        // to the bowl
        bowl.AddVegetables(item);
    }
Пример #7
0
 public void AddVegetable(Vegetable veg,Vector2 vegPosition)
 {
     if (vegPosition.x < 0 || vegPosition.x > 2 || vegPosition.y < 0 || vegPosition.y > 2) {
         Debug.LogError ("<color=green>WRONG VEGETABLE POSITION</color>");
         return;
     }
     else {
         VegetableBoard[(int)vegPosition.x,(int)vegPosition.y] = (Vegetable)Instantiate(veg);
         VegetableBoard[(int)vegPosition.x,(int)vegPosition.y].transform.SetParent(this.gameObject.transform);
         VegetableBoard[(int)vegPosition.x,(int)vegPosition.y].transform.localPosition = new Vector3(vegPosition.x * 3, 0, vegPosition.y * 3);
     }
 }
Пример #8
0
        public void Cook(Vegetable vegetable)
        {
            Potato potato = new Potato();
            potato.Peel();
            potato.Cut();

            Carrot carrot = new Carrot();
            carrot.Peel();
            carrot.Cut();

            Bowl bowl = new Bowl();
            bowl.Add(potato);
            bowl.Add(carrot);
        }
        public void Cook(Vegetable vegetable)
        {
            Potato potato = this.GetPotato();
            Carrot carrot = this.GetCarrot();

            this.Peel(potato);
            this.Peel(carrot);

            this.Cut(potato);
            this.Cut(carrot);

            Bowl bowl = this.GetBowl();
            bowl.Add(carrot);
            bowl.Add(potato);
        }
 private void Peel(Vegetable vegetable)
 {
 }
Пример #11
0
 public void AddVegetable(Vegetable veg,int xPosition,int yPosition)
 {
     AddVegetable (veg, new Vector2 (xPosition, yPosition));
 }
Пример #12
0
 public void Cut(Vegetable potato)
 {
     //...
 }
Пример #13
0
    IEnumerator TomatoScript()
    {
        Stu.Singleton.ToggleThrowing(false);

        if (cucumber == null)
        {
            cucumber = Spawn(cucumberPrefab, leftPoolSeat);
        }

        if (kidATomato == null)
        {
            kidATomato = Spawn(cherryTomatoPrefab, gateEntrace);
        }

        StartCoroutine(kidATomato.WalkTo(rightPoolEntrance));

        if (kidBTomato == null)
        {
            kidBTomato = Spawn(cherryTomatoPrefab, gateEntrace);
        }

        yield return(Dialogue.Create(kidATomato, "CANNONBALL!"));

        StartCoroutine(kidATomato.JumpTo(rightPoolSeat));

        StartCoroutine(kidBTomato.WalkTo(rightPoolEntrance));

        kidBTomato.Face.LookAt(kidATomato);

        yield return(Dialogue.Create(kidBTomato, "YOU HAVE TO WAIT FOR MOM!"));

        if (momTomato == null)
        {
            momTomato = Spawn(tomatoPrefab, gateEntrace);
        }

        kidBTomato.Face.LookAt(momTomato);

        StartCoroutine(momTomato.WalkTo(middlePoolEntrance));

        yield return(Dialogue.Create(momTomato, "Bobby, there are other people in the hottub"));

        yield return(Dialogue.Create(cucumber, "It's fine. Hop on in"));

        StartCoroutine(momTomato.JumpTo(middlePoolSeat));

        kidBTomato.Face.StopLooking();

        yield return(kidBTomato.JumpTo(farRightPoolSeat));

        yield return(Dialogue.Create(kidBTomato, "Ahhh HOT!"));

        StartCoroutine(Dialogue.Create(kidATomato, "It's a hot tub dummy!"));

        yield return(kidBTomato.TurnTo(farRightPoolSeat.rotation, true));

        yield return(kidBTomato.JumpTo(rightPoolEntrance, true));

        yield return(kidBTomato.TurnTo(rightPoolEntrance.rotation, false));

        yield return(Dialogue.Create(momTomato, "It feels so good. Oh my!"));

        StartCoroutine(momTomato.Expand(60f, new List <int>()
        {
            0, 1
        }));

        yield return(Dialogue.Create(cucumber, "We're swelling again. Stu, can you help?"));

        Stu.Singleton.ToggleThrowing(true);

        StartCoroutine(cucumber.Expand(60f, new List <int>()
        {
            0, 1
        }));

        yield return(Dialogue.Create(kidATomato, "Mom looks like an elephant!"));

        yield return(Dialogue.Create(kidBTomato, "Whoah, Mom is bigger than Jupiter!"));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(momTomato, "Children! Don't be rude"));

        yield return(momTomato.WaitTillShrunk());

        yield return(cucumber.WaitTillShrunk());

        yield return(Dialogue.Create(momTomato, "Thank you so much"));

        Stu.Singleton.ToggleThrowing(false);

        yield return(Dialogue.Create(momTomato, "I think that's enough for us"));

        StartCoroutine(kidBTomato.WalkTo(gateEntrace));

        momTomato.Face.LookAt(kidATomato);

        yield return(Dialogue.Create(momTomato, "You two need to stop acting like that potato"));

        GameObject.Destroy(kidBTomato.gameObject);

        momTomato.Face.StopLooking();

        StartCoroutine(kidATomato.JumpTo(rightPoolEntrance));

        yield return(momTomato.JumpTo(middlePoolEntrance));

        StartCoroutine(kidATomato.WalkTo(gateEntrace));

        yield return(momTomato.JumpTo(middlePoolEntrance));

        yield return(momTomato.WalkTo(gateEntrace));

        GameObject.Destroy(momTomato.gameObject);
        GameObject.Destroy(kidATomato.gameObject);
    }
Пример #14
0
 private void Peel(Vegetable vegetable)
 {
     // TODO: Implement this method
     throw new NotImplementedException();
 }
 private void Peel(Vegetable potato)
 {
     //...
 }
Пример #16
0
 private void Cut(Vegetable potato)
 {
     // ...
     throw new NotImplementedException();
 }
Пример #17
0
 private void Cut(Vegetable vegetable)
 {
     // the cutting logic here
     throw new NotImplementedException();
 }
Пример #18
0
 public void Add(Vegetable vegetable)
 {
     Console.WriteLine("{0} added to the Bowl.", vegetable.GetType().Name);
 }
Пример #19
0
 public VegetableCellPageModel(Vegetable vegetable)
 {
     _vegetable = vegetable;
 }
Пример #20
0
 Vegetable Spawn(Vegetable prefab, Transform spawnAt)
 {
     return(GameObject.Instantiate(prefab, GetPositionOfTransform(prefab, spawnAt.transform), spawnAt.transform.rotation));
 }
Пример #21
0
    IEnumerator PotatoScript()
    {
        Stu.Singleton.ToggleThrowing(false);

        if (cucumber == null)
        {
            cucumber = Spawn(cucumberPrefab, farLeftPoolSeat);
        }

        if (peach == null)
        {
            peach = Spawn(peachPrefab, rightPoolSeat);
        }

        if (pear == null)
        {
            pear = Spawn(pearPrefab, middlePoolSeat);
        }

        if (banana == null)
        {
            banana = Spawn(bananaPrefab, leftPoolSeat);
        }

        if (potato == null)
        {
            potato = Spawn(potatoPrefab, lobbyEntrace);
        }

        if (broccolli == null)
        {
            broccolli = Spawn(broccolliPrefab, farRightPoolSeat);
        }

        yield return(Dialogue.Create(pear, "Oh no..."));

        yield return(potato.WalkTo(middlePoolEntrance));

        yield return(Dialogue.Create(potato, "Hot potato comin' through!"));

        StartCoroutinePending(pear.JumpTo(leftPoolEntrance));

        StartCoroutinePending(peach.JumpTo(rightPoolEntrance));

        yield return(new WaitForSeconds(1f));

        StartCoroutinePending(pear.WalkTo(lobbyEntrace));

        StartCoroutinePending(peach.WalkTo(lobbyEntrace));

        StartCoroutinePending(banana.JumpTo(leftPoolEntrance));

        StartCoroutinePending(broccolli.JumpTo(rightPoolEntrance));

        yield return(new WaitForSeconds(1f));

        StartCoroutinePending(banana.WalkTo(lobbyEntrace));

        StartCoroutinePending(broccolli.WalkTo(sideDoorEntrace));

        StartCoroutinePending(cucumber.JumpTo(leftPoolEntrance));

        yield return(potato.JumpTo(middlePoolSeat));

        StartCoroutinePending(cucumber.WalkTo(lobbyEntrace));

        yield return(Dialogue.Create(potato, "I'm not too much for you huh?"));

        yield return(new WaitForSeconds(2f));

        yield return(WaitForPending());

        GameObject.Destroy(cucumber.gameObject);

        GameObject.Destroy(pear.gameObject);

        GameObject.Destroy(peach.gameObject);

        GameObject.Destroy(banana.gameObject);

        GameObject.Destroy(broccolli.gameObject);

        yield return(Dialogue.Create(potato, "All these other fruits and veggies can't handle a straight shooter like me"));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(potato, "I just tell it like it is, you know?"));

        Stu.Singleton.ToggleThrowing(true);

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(potato, "Like what's with that silly hand of yours? I bet you couldn't throw a syringe 3 feet.."));

        yield return(new WaitForSeconds(2f));

        StartCoroutine(potato.Expand(10f, new List <int>()
        {
            0, 1
        }));

        AudioManager.Singleton.PlayExcitingMusic();

        yield return(Dialogue.Create(potato, "Uh oh... Dagnabbit! I forgot about this part!"));

        yield return(potato.WaitTillShrunk());

        yield return(Dialogue.Create(potato, "*cough* *cough* Well... anybody could throw a syringe like that ---"));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(potato, "Oh no, here comes a big one!!!"));

        StartCoroutine(potato.Expand(19f, new List <int>()
        {
            0, 1, 2, 3, 4, 5
        }));

        yield return(new WaitForSeconds(2f));

        yield return(potato.WaitTillShrunk());

        yield return(Dialogue.Create(potato, "Wow, you've really got a knack for that. Thanks for saving me."));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(potato, "I really need to apologize for my behavior."));

        yield return(Dialogue.Create(potato, "Ever since my wife left I've been in a downward spiral..."));

        yield return(Dialogue.Create(potato, "Well, I was lucky you were here. I'll let you finally relax. Have a good night!"));

        yield return(potato.JumpTo(middlePoolEntrance));

        yield return(potato.WalkTo(gateEntrace));

        GameObject.Destroy(potato.gameObject);

        AudioManager.Singleton.PlayNormalMusic();
    }
Пример #22
0
    IEnumerator BroccoliScript()
    {
        Stu.Singleton.ToggleThrowing(false);

        if (cucumber == null)
        {
            cucumber = Spawn(cucumberPrefab, farLeftPoolSeat);
        }

        if (peach == null)
        {
            peach = Spawn(peachPrefab, rightPoolSeat);
        }

        if (pear == null)
        {
            pear = Spawn(pearPrefab, middlePoolSeat);
        }

        if (banana == null)
        {
            banana = Spawn(bananaPrefab, leftPoolSeat);
        }

        yield return(new WaitForSeconds(2f));

        peach.Face.LookAt(pear);

        yield return(new WaitForSeconds(1f));

        peach.Face.StopLooking();

        pear.Face.StopLooking();

        if (broccolli == null)
        {
            broccolli = Spawn(broccolliPrefab, gateEntrace);
        }

        yield return(broccolli.WalkTo(rightPoolEntrance));

        yield return(Dialogue.Create(broccolli, "Oh hello, it's quite the party in here"));

        yield return(broccolli.JumpTo(farRightPoolSeat));

        yield return(Dialogue.Create(banana, "WOOOO! we love to party!!! right ladies??"));

        yield return(new WaitForSeconds(2f));

        yield return(Dialogue.Create(peach, "Oh great, now there's more of them."));

        pear.Face.LookAt(peach);

        yield return(new WaitForSeconds(1f));

        pear.Face.LookAt(banana);
        yield return(Dialogue.Create(pear, "Oh yea, we're crazy."));

        pear.Face.LookAt(peach);

        yield return(new WaitForSeconds(1.5f));

        peach.Face.LookAt(pear);
        yield return(Dialogue.Create(peach, "Linda, please!"));

        peach.Face.StopLooking();
        pear.Face.StopLooking();

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(broccolli, "The water is nice..."));

        StartCoroutine(broccolli.Expand(30f, new List <int>()
        {
            0, 1
        }));

        yield return(Dialogue.Create(broccolli, "woop, spoke too soon"));

        AudioManager.Singleton.PlayExcitingMusic();
        Stu.Singleton.ToggleThrowing(true);

        StartCoroutine(cucumber.Expand(30f, new List <int>()
        {
            0
        }));

        yield return(Dialogue.Create(cucumber, "Ack! us too"));

        StartCoroutine(banana.Expand(30f, new List <int>()
        {
            0
        }));

        StartCoroutine(peach.Expand(30f, new List <int>()
        {
            0
        }));

        StartCoroutine(pear.Expand(30f, new List <int>()
        {
            0
        }));

        yield return(broccolli.WaitTillShrunk());

        yield return(cucumber.WaitTillShrunk());

        yield return(banana.WaitTillShrunk());

        yield return(peach.WaitTillShrunk());

        yield return(pear.WaitTillShrunk());

        yield return(Dialogue.Create(broccolli, "Impressive!"));

        AudioManager.Singleton.PlayNormalMusic();
    }
Пример #23
0
    IEnumerator PeachStrawberryScript()
    {
        Stu.Singleton.ToggleThrowing(false);

        if (cucumber == null)
        {
            cucumber = Spawn(cucumberPrefab, leftPoolSeat);
        }

        if (peach == null)
        {
            peach = Spawn(peachPrefab, lobbyEntrace);
        }

        StartCoroutinePending(peach.WalkTo(rightPoolEntrance));

        yield return(new WaitForSeconds(.5f));

        StartCoroutine(Dialogue.Create(peach, "Can you believe the nerve of that guy?"));

        yield return(new WaitForSeconds(.5f));

        cucumber.Face.LookAt(peach);

        if (pear == null)
        {
            pear = Spawn(pearPrefab, lobbyEntrace);
        }

        StartCoroutinePending(pear.WalkTo(middlePoolEntrance));

        yield return(new WaitForSeconds(4f));

        StartCoroutinePending(Dialogue.Create(pear, "Seriously, he's just a spin instructor."));

        yield return(WaitForPending());

        yield return(new WaitForSeconds(1f));

        yield return(peach.JumpTo(rightPoolSeat));

        yield return(pear.JumpTo(middlePoolSeat));

        yield return(new WaitForSeconds(2f));

        yield return(Dialogue.Create(cucumber, "Hey, how you ladies doing today?"));

        yield return(new WaitForSeconds(0.5f));

        peach.Face.LookAt(farRightPoolSeat);
        yield return(Dialogue.Create(peach, "Ugh ..."));

        pear.Face.LookAt(cucumber);

        yield return(Dialogue.Create(pear, "Pretty good, what about you?"));

        cucumber.Face.LookAt(pear);

        yield return(Dialogue.Create(cucumber, "Great, I'm enjoying all these bubbles!"));

        yield return(Dialogue.Create(pear, "Oh, I bet you are!"));

        peach.Face.LookAt(pear);

        pear.Face.LookAt(peach);
        yield return(Dialogue.Create(peach, "Linda, don't encourage him."));

        yield return(new WaitForSeconds(0.5f));

        pear.Face.LookAt(peach);
        yield return(Dialogue.Create(pear, "What, he's kinda cute."));

        peach.Face.StopLooking();
        yield return(Dialogue.Create(peach, "Whatever."));

        // expansion begins
        StartCoroutine(cucumber.Expand(60f, new List <int>()
        {
            0
        }));

        StartCoroutine(peach.Expand(60f, new List <int>()
        {
            0
        }));

        StartCoroutine(pear.Expand(60f, new List <int>()
        {
            0
        }));

        Stu.Singleton.ToggleThrowing(true);

        peach.Face.StopLooking();
        pear.Face.StopLooking();
        cucumber.Face.StopLooking();

        yield return(new WaitForSeconds(3f));

        cucumber.Face.LookAt(pear);

        yield return(Dialogue.Create(cucumber, "You guys on business or vacation?"));

        pear.Face.LookAt(cucumber);

        yield return(Dialogue.Create(pear, "We're here for a wedding."));

        yield return(Dialogue.Create(cucumber, "Nice, I love weddings, they're so much fun."));

        peach.Face.LookAt(cucumber);

        yield return(Dialogue.Create(peach, "I'm the maid of honor."));

        cucumber.Face.LookAt(peach);

        yield return(Dialogue.Create(cucumber, "Ok ...~~ that's cool I guess."));

        cucumber.Face.StopLooking();
        peach.Face.StopLooking();
        pear.Face.StopLooking();

        yield return(cucumber.WaitTillShrunk());

        yield return(peach.WaitTillShrunk());

        yield return(pear.WaitTillShrunk());

        yield return(new WaitForSeconds(3f));
    }
Пример #24
0
 private void Cook(Vegetable vegetable)
 {
     Console.WriteLine("Cooking {0}", vegetable);
 }
Пример #25
0
 private void Peel(Vegetable vegetable)
 {
     Console.WriteLine("Peeling {0}", vegetable);
 }
Пример #26
0
 private void Peel(Vegetable vegetable)
 {
     // the peeling logic here
     throw new NotImplementedException();
 }
Пример #27
0
 private void Peel(Vegetable vegetable)
 {
     vegetable.Peel();
 }
Пример #28
0
        private void Peel(Vegetable anyVegetable)
        {
            uint waste = 5;

            anyVegetable.Weight -= waste;
        }
Пример #29
0
 private void Peel(Vegetable vegetable)
 {
     // some vegetable peeling logic
     vegetable.IsPeeled = true;
 }
Пример #30
0
 private void Cut(Vegetable someVegetable)
 {
     // ...
 }
Пример #31
0
 public void Add(Vegetable vegetable)
 {
 }
 private static void SwitchClassByRef(ref Thing pValue)
 {
     pValue = new Vegetable();
 }
Пример #33
0
 internal void Add(Vegetable vegetable)
 {
     // ...
 }
Пример #34
0
 private void Cut(Vegetable potato)
 {
     Peel(potato);
 }
        public void Run()
        {
            List <IAnimal> animals = new List <IAnimal>();
            string         input;

            while ((input = Console.ReadLine()) != "End")
            {
                string[] animalTokens = input.Split();
                string   animalType   = animalTokens[0];
                string   name         = animalTokens[1];
                double   weight       = double.Parse(animalTokens[2]);
                IAnimal  currAnimal   = null;
                switch (animalType)
                {
                case nameof(Owl):
                    double wingSize = double.Parse(animalTokens[3]);
                    currAnimal = new Owl(name, weight, wingSize);
                    break;

                case nameof(Hen):
                    wingSize   = double.Parse(animalTokens[3]);
                    currAnimal = new Hen(name, weight, wingSize);
                    break;

                case nameof(Mouse):
                    string livingRegion = animalTokens[3];
                    currAnimal = new Mouse(name, weight, livingRegion);
                    break;

                case nameof(Dog):
                    livingRegion = animalTokens[3];
                    currAnimal   = new Dog(name, weight, livingRegion);
                    break;

                case nameof(Cat):
                    livingRegion = animalTokens[3];
                    string breed = animalTokens[4];
                    currAnimal = new Cat(name, weight, livingRegion, breed);
                    break;

                case nameof(Tiger):
                    livingRegion = animalTokens[3];
                    breed        = animalTokens[4];
                    currAnimal   = new Tiger(name, weight, livingRegion, breed);
                    break;

                default:
                    break;
                }

                string[] foodTokens = Console.ReadLine().Split();
                string   foodType   = foodTokens[0];
                int      quantity   = int.Parse(foodTokens[1]);
                IFood    food       = null;
                switch (foodType)
                {
                case nameof(Meat):
                    food = new Meat(quantity);
                    break;

                case nameof(Vegetable):
                    food = new Vegetable(quantity);

                    break;

                case nameof(Seeds):
                    food = new Seeds(quantity);

                    break;

                case nameof(Fruit):
                    food = new Fruit(quantity);

                    break;

                default:
                    break;
                }

                Console.WriteLine(currAnimal.AskForFood());
                bool hasEaten = currAnimal.EatFood(food);
                if (!hasEaten)
                {
                    Console.WriteLine($"{animalType} does not eat {foodType}!");
                }
                animals.Add(currAnimal);
            }

            foreach (IAnimal animal in animals)
            {
                Console.WriteLine(animal.ToString());
            }
        }
Пример #36
0
 internal void Add(Vegetable vegetable)
 {
     Console.WriteLine(vegetable.ToString() + " is in the bowl");
 }
Пример #37
0
 public void Add(Vegetable vegetable)
 {
     _vegetables.Add(vegetable);
 }
Пример #38
0
        //place order

        public void PlaceOrder(Vegetable vegetable)
        {
            _inventoryManager.Add(vegetable, _defaultOrderQuantity);
        }
Пример #39
0
 internal void Add(Vegetable vegetable)
 {
 }
Пример #40
0
 private void Cut(Vegetable potato)
 {
     //...
 }
Пример #41
0
 private void Cut(Vegetable vegetable)
 {
     Console.WriteLine("Cutting {0}...", vegetable);
 }
Пример #42
0
 private void Peel(Vegetable vegetable)
 {
     // Peel veggie
 }
Пример #43
0
 private void Peel(Vegetable vegetable)
 {
     // ... 
     throw new NotImplementedException();
 }
Пример #44
0
        public async Task <IActionResult> ValidateSessionCart()
        {
            Order cartOrder = ShoppingCart.GetCartContent(User, HttpContext);

            Company companyDb = _context.Companies.First();

            //Si la company n'est visible en DB, c'est qui il y a un gros problème.
            if (companyDb == null)
            {
                return(NotFound());//Ou page d'erreur
            }

            CommWrap <OrderGuid_Com> comm = await RemoteCall.GetInstance().SendOrder(cartOrder, companyDb);

            if (comm.RequestStatus == 0)
            {
                //Si une erreur est survenue sur le serveur : company pas trouvée, erreur Db, ...
                return(NotFound());//Or pas d'erreur
            }
            Order  orderUpdatedByServ = comm.Content.Order_com;
            string orderUpdatedGuid   = comm.Content.Guid_com;

            string employeeId = _userManager.GetUserId(User);
            var    employeeDb = await _context.Employees.SingleOrDefaultAsync(m => m.Id == employeeId);

            bool reussite = employeeDb.DebitWallet(orderUpdatedByServ.TotalAmount);

            if (reussite == false)
            {
                ModelState.AddModelError(string.Empty, "Porte monnaie insuffisant");
                //L'employé n'a pas suffisement d'argent.
                CommWrap <string> commCancellation = await RemoteCall.GetInstance().ConfirmOrder(false, orderUpdatedGuid);

                return(await Index());

                if (commCancellation.RequestStatus != 0)
                {
                    //Il faut afficher à l'utilisateur qu'il n'a pas assez d'argent.
                    //return
                }
                //L'annulation n'a pas aboutie, si on arrive ici, c'est que quelque
                //chose d'inattendu s'est produit ou peut être que la requête a été
                //appelée manuelle par l'utilisateur.
                //return
            }

            //L'employé avait suffisement de crédit et sa commande se confirme.
            CommWrap <string> commConfirmation = await RemoteCall.GetInstance().ConfirmOrder(true, orderUpdatedGuid);

            if (commConfirmation.RequestStatus != 0)
            {
                //Sauvegarder dans la DB coté client


                using (var tx = _context.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                {
                    Order orderDb = await _context.Orders
                                    .Include(order => order.OrderLines)
                                    .ThenInclude(odLin => odLin.Sandwich)
                                    .Include(order => order.OrderLines)
                                    .ThenInclude(odLin => odLin.OrderLineVegetables)
                                    .ThenInclude(odLinVeg => odLinVeg.Vegetable)
                                    .SingleOrDefaultAsync(o => o.Employee.Equals(employeeDb) && o.DateOfDelivery.Equals(orderUpdatedByServ.DateOfDelivery));

                    if (orderDb == null)
                    {
                        //Si aucune commande pour cette journée n'a été trouvée, on lui assigne la nouvelle commande.
                        for (int i = 0; i < orderUpdatedByServ.OrderLines.Count; i++)
                        {
                            Sandwich sandwichTemp = await _context.Sandwiches.SingleOrDefaultAsync(s => s.Id == orderUpdatedByServ.OrderLines.ElementAt(i).Sandwich.Id);

                            if (sandwichTemp != null)
                            {
                                orderUpdatedByServ.OrderLines.ElementAt(i).Sandwich = sandwichTemp;
                            }
                            //_context.Entry(orderInValidation.OrderLines.ElementAt(i).Sandwich).State = EntityState.Unchanged;

                            for (int j = 0; j < orderUpdatedByServ.OrderLines.ElementAt(i).OrderLineVegetables.Count; j++)
                            {
                                Vegetable vegetableTemp = await _context.Vegetables.SingleOrDefaultAsync(s => s.Id == orderUpdatedByServ.OrderLines.ElementAt(i).OrderLineVegetables.ElementAt(j).Vegetable.Id);

                                if (vegetableTemp != null)
                                {
                                    orderUpdatedByServ.OrderLines.ElementAt(i).OrderLineVegetables.ElementAt(j).Vegetable = vegetableTemp;
                                }
                                //_context.Entry(orderInValidation.OrderLines.ElementAt(i).OrderLineVegetables.ElementAt(j).Vegetable).State = EntityState.Unchanged;
                            }
                        }
                        employeeDb.Orders.Add(orderUpdatedByServ);
                    }
                    else
                    {
                        //Une commande à été trouvé pour la journée, on somme celle-ci avec la nouvelle.
                        orderDb.SumUpOrders(orderUpdatedByServ);
                    }

                    _context.SaveChanges();
                    tx.Commit();
                }



                //Tout s'est bien passé, on peut vider le panier
                ShoppingCart.UpdateCartContent(HttpContext, null);
                return(RedirectToAction("Index"));
            }

            //La confirmation n'a pas aboutie, si on arrive ici, c'est que quelque
            //chose d'inattendu s'est produit ou peut être que la requête a été
            //appelée manuelle par l'utilisateur.
            //return
            return(RedirectToAction("Index"));//temporaire juste le temps des tests
        }
Пример #45
0
 private void Cut(Vegetable vegetable)
 {
     vegetable.Cut();
 }
Пример #46
0
 public void Add(Vegetable vegetable)
 {
     //...
 }
Пример #47
0
 private void Cut(Vegetable vegetable)
 {
     // ...
 }
Пример #48
0
 private void Cut(Vegetable vegetable)
 {
     // Cut the vegetable
 }
Пример #49
0
 private void Cut(Vegetable vegetable)
 {
     // some vegetable cutting logic
     vegetable.IsCut = true;
 }
Пример #50
0
 private void Peel(Vegetable vegetable)
 {
     // Peel the vegetable
 }
Пример #51
0
 internal void Add(Vegetable carrot)
 {
     throw new NotImplementedException();
 }
Пример #52
0
    public static void Main(string[] args)
    {
        List <Animal> animals = new List <Animal>();

        Animal currentAnimal = null;
        int    currentLine   = 0;

        while (true)
        {
            string command = Console.ReadLine();

            if (command == "End")
            {
                break;
            }

            string[] tokens = command.Split();

            if (currentLine == 0 || currentLine % 2 == 0)
            {
                Animal animal = null;

                string name   = tokens[1];
                double weight = double.Parse(tokens[2]);

                if (tokens[0] == "Cat")
                {
                    string livingRegion = tokens[3];
                    string breed        = tokens[4];

                    animal = new Cat(name, weight, livingRegion, breed);
                    animals.Add(animal);
                }
                else if (tokens[0] == "Tiger")
                {
                    string livingRegion = tokens[3];
                    string breed        = tokens[4];

                    animal = new Tiger(name, weight, livingRegion, breed);
                    animals.Add(animal);
                }
                else if (tokens[0] == "Dog")
                {
                    string livingRegion = tokens[3];

                    animal = new Dog(name, weight, livingRegion);
                    animals.Add(animal);
                }
                else if (tokens[0] == "Mouse")
                {
                    string livingRegion = tokens[3];

                    animal = new Mouse(name, weight, livingRegion);
                    animals.Add(animal);
                }
                else if (tokens[0] == "Hen")
                {
                    double wingSize = double.Parse(tokens[3]);
                    animal = new Hen(name, weight, wingSize);
                    animals.Add(animal);
                }
                else if (tokens[0] == "Owl")
                {
                    double wingSize = double.Parse(tokens[3]);
                    animal = new Owl(name, weight, wingSize);
                    animals.Add(animal);
                }

                currentAnimal = animal;
                animal.ProduceSound();
            }
            else
            {
                int quantity = int.Parse(tokens[1]);
                try
                {
                    if (tokens[0] == "Fruit")
                    {
                        Fruit fruit = new Fruit(quantity);
                        currentAnimal.Eat(fruit);
                    }
                    else if (tokens[0] == "Meat")
                    {
                        Meat meat = new Meat(quantity);
                        currentAnimal.Eat(meat);
                    }
                    else if (tokens[0] == "Seeds")
                    {
                        Seeds seeds = new Seeds(quantity);
                        currentAnimal.Eat(seeds);
                    }
                    else if (tokens[0] == "Vegetable")
                    {
                        Vegetable vegetable = new Vegetable(quantity);
                        currentAnimal.Eat(vegetable);
                    }
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            currentLine++;
        }

        foreach (var animal in animals)
        {
            Console.WriteLine(animal);
        }
    }
Пример #53
0
 private void Cut(Vegetable potato)
 {
     // ...
 }
Пример #54
0
 internal void Add(Vegetable vegetable)
 {
     throw new System.NotImplementedException();
 }
Пример #55
0
 public void Add(Vegetable vegetable)
 {
     this.vegetables.Add(vegetable);
 }
Пример #56
0
    IEnumerator CucumberScript()
    {
        Stu.Singleton.ToggleThrowing(false);

        yield return(new WaitForSeconds(1f));

        if (cucumber == null)
        {
            cucumber = Spawn(cucumberPrefab, lobbyEntrace);
        }

        yield return(cucumber.WalkTo(middlePoolEntrance));

        cucumber.Face.LookAt(Stu.Singleton);

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(cucumber, "Hey there!"));

        yield return(Dialogue.Create(cucumber, "How's the water?"));

        yield return(new WaitForSeconds(1f));

        yield return(cucumber.JumpTo(middlePoolSeat));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(cucumber, "I'm Paul. What's your name?"));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(cucumber, "Stu, huh?"));

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(cucumber, "Oh man Stu... This is embarrassing, but I'm swelling up"));

        StartCoroutine(cucumber.Expand(30f, new List <int>()
        {
            0
        }));

        yield return(new WaitForSeconds(1f));

        StartCoroutine(Dialogue.Create(cucumber, "Toss me some saline solution will ya?"));

        yield return(new WaitForSeconds(1f));

        Stu.Singleton.ToggleThrowing(true);

        yield return(cucumber.WaitTillShrunk());

        yield return(Dialogue.Create(cucumber, "Oh god, thanks. That felt great!"));

        yield return(new WaitForSeconds(1f));

        cucumber.Face.LookAt(gateEntrace);

        yield return(new WaitForSeconds(1f));

        yield return(Dialogue.Create(cucumber, "Looks like we've got company", 3f));

        cucumber.Face.StopLooking();

        yield return(cucumber.WalkTo(leftPoolSeat));
    }
Пример #57
0
        private void Cut(Vegetable vegitable)
        {

        }
 private void Peel(Vegetable vegetable)
 {
     ////...
 }
Пример #59
0
 public void Add(Vegetable vegetable)
 {
     this.Ingredients.Add(vegetable);
 }
 private void Cut(Vegetable vegetable)
 {
     ////...
 }