Пример #1
0
        public IFood Create(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type)
            {
            case "Dessert":
                food = new Dessert(name, price);
                break;

            case "MainCourse":
                food = new MainCourse(name, price);
                break;

            case "Salad":
                food = new Salad(name, price);
                break;

            case "Soup":
                food = new Soup(name, price);
                break;
            }

            return(food);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            //[1] 밥 만들기
            Rice rice = (new Cooking()).MakeRice(); // 스레드 차단: true

            Console.WriteLine($"밥 준비 완료 - {rice.GetHashCode()}");

            //[2] 국 만들기
            Soup soup = (new Cooking()).MakeSoup();

            Console.WriteLine($"국 준비 완료 - {soup.GetHashCode()}");

            //[3] 달걀 만들기
            Egg egg = (new Cooking()).MakeEgg();

            Console.WriteLine($"달걀 준비 완료 - {egg.GetHashCode()}");

            stopwatch.Stop();

            Console.WriteLine($"\n시간: {stopwatch.ElapsedMilliseconds}밀리초");
            Console.WriteLine("동기 방식으로 식사 준비 완료");
        }
        static void Main(string[] args)
        {
            List <string> avVegetables = new List <string>
            {
                "carrots",
                "tomatos",
                "potatos",
                "onion",
                "garlic"
            };

            List <string> avSpices = new List <string>
            {
                "salt",
                "pepper",
                "basil"
            };

            Chef chef       = new Chef();
            Soup tomatoSoup = chef.PrepareSoup(new TomatoSoupCook(), avVegetables, avSpices);

            tomatoSoup.GetLabel();


            avVegetables.Add("chicken meat");
            Soup chickenSoup = chef.PrepareSoup(new ChickenSoupCook(), avVegetables, avSpices);

            chickenSoup.GetLabel();

            Console.Read();
        }
Пример #4
0
    public void Empty()
    {
        GameObject o = Instantiate(soup.gameObject);

        soup      = o.GetComponent <Soup>();
        sp.sprite = empty;
    }
Пример #5
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type.ToLower())
            {
            case "dessert":
                food = new Dessert(name, price);
                break;

            case "salad":
                food = new Salad(name, price);
                break;

            case "soup":
                food = new Soup(name, price);
                break;

            case "maincourse":
                food = new MainCourse(name, price);
                break;

            default: throw new ArgumentException($"Invalid food type {type}!");
            }

            this.menu.Add(food);
            return($"Added {food.Name} ({type}) with price {food.Price:f2} to the pool");
        }
Пример #6
0
        public IProduct CreatePOCOProduct(Product product)
        {
            IProduct pocoProduct = null;

            switch (product.ProductType)
            {
            case ProductType.Pizza:
                pocoProduct = new Pizza(product.Name, product.Price, product.Remarks);
                break;

            case ProductType.PizzaTopping:
                pocoProduct = new PizzaTopping(product.Name, product.Price);
                break;

            case ProductType.MainCourse:
                pocoProduct = new MainCourse(product.Name, product.Price);
                break;

            case ProductType.MainCourseSideDish:
                pocoProduct = new MainCourseSideDish(product.Name, product.Price);
                break;

            case ProductType.Beverage:
                pocoProduct = new Beverage(product.Name, product.Price);
                break;

            case ProductType.Soup:
                pocoProduct = new Soup(product.Name, product.Price);
                break;

            default:
                break;
            }
            return(pocoProduct);
        }
Пример #7
0
        private void SetSoupRating(Comment comment)
        {
            var sumSoupRatings = 0;

            double soupRating;

            Lunch lunch = db.Lunches.Find(comment.LunchId);

            var soupId = lunch.SoupId;

            int countSoupRatings = db.Comments.Where(c => c.Lunch.SoupId == soupId).Count();

            if (countSoupRatings == 0)
            {
                soupRating = comment.SoupRating;
            }
            else
            {
                sumSoupRatings = db.Comments.Include(c => c.Lunch).Where(c => c.Lunch.SoupId == soupId).Sum(c => c.SoupRating);

                soupRating = (double)(sumSoupRatings + comment.SoupRating) / (countSoupRatings + 1);
            }

            Soup soup = db.Soups.Find(soupId);

            soup.Rating = soupRating;

            db.Entry(soup).State = EntityState.Modified;
        }
Пример #8
0
        private void btnMakeDinner_Click(object sender, EventArgs e)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            //[1] 밥 만들기
            Rice rice = (new Cooking()).MakeRice();

            lblDisplay.Text = $"밥 준비 완료 - {rice.GetHashCode()}";

            //[2] 국 만들기
            Soup soup = (new Cooking()).MakeSoup();

            lblDisplay.Text = $"국 준비 완료 - {soup.GetHashCode()}";

            //[3] 달걀 만들기
            Egg egg = (new Cooking()).MakeEgg();

            lblDisplay.Text = $"달걀 준비 완료 - {egg.GetHashCode()}";

            stopwatch.Stop();
            lblDisplay.Text = $"\n시간: {stopwatch.ElapsedMilliseconds}밀리초";

            lblDisplay.Text = ("동기 방식으로 식사 준비 완료");
        }
Пример #9
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood  food   = null;
            string output = string.Empty;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            else if (type == "Soup")
            {
                food = new Soup(name, price);
                menu.Add(food);
                output = $"Added {name} ({type}) with price {price:f2} to the pool";
            }
            return(output);
        }
Пример #10
0
    // ---------------------------------------------------------------------------------------------------------------------------------------------------------------- //


    // ------------------------- After we "CookSoup()", we use the returned soup and create a Soup object and attach the appropriate Soup stats to the SoupData script. ------------------------- //
    public void MakeSoup()
    {
        Soup newSoup = CookSoup();

        Transform newSoupOrb = GameObject.Instantiate(soupOrb, soupOrb.position, soupOrb.rotation);

        // The setting active is moved to the State Machine because of the added cooking timer mechanic. //
        //newSoupOrb.gameObject.SetActive(true);

        SoupData newSoupsData = newSoupOrb.GetComponent <SoupData>();

        newSoupsData.theSoup = newSoup;

        // Setting max amount of "portions" of soup. The player can keep grabbing soup until they've depleted all the portions. //

        // Hey get out of here! If you want to set the portion sizes do it through the inspector ! //

        //newSoupsData.currentPortions = 5;
        //newSoupsData.maxPortions = 5;

        occupyingSoup = newSoupOrb;

        // Setting the colour of the occupying soup. //
        Material newMaterial = new Material(waterShader);

        newMaterial.SetColor("Color_6EDA1D08", gameManager.colourManager.ConvertColour(newSoup.colour));
        occupyingSoup.GetComponent <Renderer>().material = newMaterial;


        // Removing and resetting stuff to do with the water display. //
        RemoveWater();
    }
Пример #11
0
        public IFood CreateFood(string type, string name, decimal price)
        {
            IFood food = null;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
            }
            else if (type == "Soup")
            {
                food = new Soup(name, price);
            }
            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
            }
            else
            {
                throw new InvalidOperationException("Invalid food type!");
            }

            return(food);
        }
Пример #12
0
        public void Run()
        {
            List <Product> products = new List <Product>();

            ColdBeverage coldBeverage = new ColdBeverage("Coka-Cola", 1.20M, 0.750);

            Coffee coffee = new Coffee("Expreso", 500);
            Tea    tea    = new Tea("Black", 0.90M, 200);

            Cake cake = new Cake("Choco");
            Soup soup = new Soup("Chicken", 2.20M, 200);
            Fish fish = new Fish("Hake", 3.60M);

            products.Add(coldBeverage);
            products.Add(coffee);
            products.Add(tea);
            products.Add(cake);
            products.Add(soup);
            products.Add(fish);

            foreach (Product product in products)
            {
                Console.WriteLine(product.ToString());
            }
        }
Пример #13
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Soup soup)
        {
            if (!ModelState.IsValid)
            {
                string msg = (ModelState.FirstOrDefault(x => x.Value.Errors.Any()).Value.Errors.FirstOrDefault().ErrorMessage).Replace("'", "");
                _toastNotification.AddErrorToastMessage(msg);

                return(View(soup));
            }
            if (ModelState.IsValid)
            {
                var checkExit = _context.Soup.Where(x => x.Name.ToLower() == soup.Name.ToLower()).Count();

                if (checkExit == 0)
                {
                    _context.Add(soup);
                    await _context.SaveChangesAsync();

                    _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.CREATED_SUCESSFUL);
                    return(RedirectToAction(nameof(Index)));
                }
                _toastNotification.AddErrorToastMessage(ResponseMessageUtilities.ITEM_EXIST);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(soup));
        }
Пример #14
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            if (type == "Dessert")
            {
                food = new Dessert(name, price);
            }
            else if (type == "Salad")
            {
                food = new Salad(name, price);
            }

            else if (type == "Soup")
            {
                food = new Soup(name, price);
            }

            else if (type == "MainCourse")
            {
                food = new MainCourse(name, price);
            }

            if (food != null)
            {
                this.menu.Add(food);
            }


            return($"Added {food.Name} ({food.GetType().Name}) with price {food.Price:F2} to the pool");
        }
Пример #15
0
        public string AddFood(string type, string name, decimal price)
        {
            IFood food = null;

            switch (type)
            {
            case "Dessert":
                food = new Dessert(name, price);
                break;

            case "MainCourse":
                food = new MainCourse(name, price);
                break;

            case "Salad":
                food = new Salad(name, price);
                break;

            case "Soup":
                food = new Soup(name, price);
                break;
            }

            menu.Add(food);

            return($"Added {name} ({type}) with price {price:f2} to the pool");
        }
Пример #16
0
        public IntersectionTest()
        {
            var           dataGenerator = IoC.Services.GetService <TestDataGenerator>();
            SoupGenerator generator     = dataGenerator.InitGenerator(allowedDirections: Directions.E | Directions.N);

            soup = generator.Init().Soup;
        }
Пример #17
0
        public Cheff(RestaurantFactory restaurantFactory)
        {
            this.restaurantFactory = restaurantFactory;

            this.soup    = restaurantFactory.CreateSoup();
            this.meal    = restaurantFactory.CreateMeal();
            this.dessert = restaurantFactory.CreateDessert();
        }
Пример #18
0
        public EntityEditor(Soup soup)
        {
            var settings = new SimulationSettings();

            _simulation            = new EntityEditorSimulation(soup.Window, settings);
            soup.CurrentSimulation = _simulation;
            BuildUI();
        }
Пример #19
0
        private static List <Soup> GetSoups(HtmlNode day)
        {
            var soup = new Soup(day.SelectNodes(".//td[2]")[0].InnerText);

            return(new List <Soup> {
                soup
            });
        }
Пример #20
0
        public ActionResult DeleteConfirmed(int id)
        {
            Soup soup = db.Soups.Find(id);

            db.Soups.Remove(soup);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #21
0
    private void Start()
    {
        GameObject o = Instantiate(soup.gameObject);

        o.transform.parent = transform;
        soup  = o.GetComponent <Soup>();
        sp    = GetComponent <SpriteRenderer>();
        empty = sp.sprite;
    }
Пример #22
0
        public MainUI(Soup soup)
        {
            BuildUI();

            _quit.Selected += (s, a) =>
            {
                soup.EndExperiment();
            };
        }
Пример #23
0
        public void MatrixDimensions()
        {
            Soup soup = new Soup {
                Matrix = new char[10, 5]
            };

            Assert.Equal(10, soup.Matrix.GetLength(0)); //The X axis
            Assert.Equal(5, soup.Matrix.GetLength(1));  //The Y axis
        }
Пример #24
0
 public ActionResult Edit([Bind(Include = "Id,Category,Name,ShortDescription,LongDescription,ThumbnailImage,FullImage,Price")] Soup soup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(soup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(soup));
 }
Пример #25
0
    public void LoadCanon(Soup theDataToLoad)
    {
        isLoaded = true;


        // Actual loading of soup data. //
        canonCapsule.GetComponent <SoupData>().theSoup = theDataToLoad;
        Debug.Log("Canon loaded and received data successfully.");
        currentSoup = canonCapsule.GetComponent <SoupData>();
    }
Пример #26
0
        public IActionResult Delete([FromBody] Soup product)
        {
            var result = this.productsRepository.DeleteProduct(product);

            if (result == false)
            {
                return(new StatusCodeResult(202));
            }
            return(new JsonResult(result));
        }
Пример #27
0
        public IActionResult Put([FromBody] Soup value)
        {
            var result = this.productsRepository.UpdateProduct(value);

            if (result == false)
            {
                return(new StatusCodeResult(202));
            }
            return(new JsonResult(result));
        }
Пример #28
0
 public ActionResult Edit([Bind(Include = "Id,Item,Description,Image,Price")] Soup soup)
 {
     if (ModelState.IsValid)
     {
         db.Entry(soup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(soup));
 }
Пример #29
0
 public ActionResult Edit([Bind(Include = "SoupId,SoupName,SoupshortDescription,SoupLongDescription,SoupPrice,SoupImage")] Soup Soup)
 {
     if (ModelState.IsValid)
     {
         // db.Entry(Soup).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Admin"));
     }
     return(View(Soup));
 }
Пример #30
0
        public ActionResult Create([Bind(Include = "Id,Item,Description,Image,Price")] Soup soup)
        {
            if (ModelState.IsValid)
            {
                db.Soups.Add(soup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(soup));
        }