Example #1
0
        private void btnAddOrder_Click(object sender, EventArgs e)
        {
            AnyMeal aMeal;

            int    X        = Convert.ToInt32(txtXpos.Text);
            int    Y        = Convert.ToInt32(txtYpos.Text);
            double price    = Convert.ToDouble(txtPrice.Text);
            bool   takeAway = checkBoxTakeAway.Checked;

            int time = orderTime();

            if (rbPizza.Checked)
            {
                //aShape = new AnyCircle("circle", X, Y, Width, Height, aColor);
                //myModel.AddShape(aShape);

                string aFlavor = "vegetable";
                if (lblColor.BackColor == labelSeafood.BackColor)
                {
                    aFlavor = "seafood";
                }
                else if (lblColor.BackColor == labelBBQ.BackColor)
                {
                    aFlavor = "BBQ";
                }
                else if (lblColor.BackColor == labelBeef.BackColor)
                {
                    aFlavor = "Beef";
                }
                else
                {
                }

                aMeal = new AnyPizza(takeAway, price, time, X, Y, aFlavor);
                myModel.AddMealOrder(aMeal);
            }
            else if (rbNoodle.Checked)
            {
                bool spicyValue = false;
                if (checkBoxIfSpicy.Checked == true)
                {
                    spicyValue = true;
                }
                aMeal = new AnyNoodle(takeAway, price, time, X, Y, spicyValue);
                myModel.AddMealOrder(aMeal);
            }
            else
            {
                int size = getCakeSize();
                aMeal = new AnyCake(takeAway, price, time, X, Y, size);
                myModel.AddMealOrder(aMeal);
            }
        }
Example #2
0
        public void AddMealByString(string mealStr)
        {
            AnyMeal aMeal;

            string[] parts = mealStr.Split(',');
            if (parts.Length > 1)
            {
                string mealName = parts[0];
                bool   takeAway = Convert.ToBoolean(parts[1]);
                double price    = Convert.ToDouble(parts[2]);
                int    time     = Convert.ToInt32(parts[3]);

                int x = Convert.ToInt32(parts[4]);
                int y = Convert.ToInt32(parts[5]);
                if (parts[0] == "Pizza")
                {
                    aMeal = new AnyPizza(takeAway, price, time, x, y, parts[6]);
                    myModel.AddMealOrder(aMeal);
                }
                else if (parts[0] == "Noodle")
                {
                    aMeal = new AnyNoodle(takeAway, price, time, x, y, Convert.ToBoolean(parts[6]));
                    myModel.AddMealOrder(aMeal);
                }
                else if (parts[0] == "Cake")
                {
                    aMeal = new AnyCake(takeAway, price, time, x, y, Convert.ToInt32(parts[6]));
                    myModel.AddMealOrder(aMeal);
                }
                else
                {
                }
            }
        }