コード例 #1
0
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                Debug.Log($"Description: {_beverage.GetDescription()}");
                Debug.Log($"Cost: {_beverage.Cost()}");
            }

            if (Input.GetKeyDown(KeyCode.D))
            {
                _beverage = new DarkRoast();
                _beverage = new Whip(_beverage);
                _beverage = new Milk(_beverage);
            }
            else if (Input.GetKeyDown(KeyCode.H))
            {
                _beverage = new HouseBlend();
                _beverage = new Whip(_beverage);
            }
            else if (Input.GetKeyDown(KeyCode.E))
            {
                _beverage = new Espresso();
                _beverage = new Whip(_beverage);
            }
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: Technopark95/CoffeeShop
        public void SelectAddOns()
        {
            MenuInput TakeInput = new MenuInput();

            Console.WriteLine(Constants.SelectAddOnsMenu);
            Console.WriteLine(Constants.AddOnsMenuInstruction);

            while (true)
            {
                char Choice = TakeInput.SelectAddOnInput();
                if (Choice == Constants.IncorrectInput)
                {
                    continue;
                }
                Console.Write(" -> ");

                if (Choice == '1')
                {
                    Caramel Custom = new Caramel(_menuItem, Constants.CaramelCost);
                    _menuItem = Custom;
                    Console.WriteLine("Status : " + _menuItem.GetDescription());
                }

                if (Choice == '2')
                {
                    Chocolate Custom = new Chocolate(_menuItem, Constants.ChocolateCost);
                    _menuItem = Custom;
                    Console.WriteLine("Status : " + _menuItem.GetDescription());
                }

                if (Choice == '3')
                {
                    Cream Custom = new Cream(_menuItem, Constants.CreamCost);
                    _menuItem = Custom;
                    Console.WriteLine("Status : " + _menuItem.GetDescription());
                }

                if (Choice == '4')
                {
                    Honey Custom = new Honey(_menuItem, Constants.HoneyCost);
                    _menuItem = Custom;
                    Console.WriteLine("Status : " + _menuItem.GetDescription());
                }

                if (Choice == '0')
                {
                    Console.WriteLine("Exit");
                    break;
                }

                _totalCost   = _menuItem.GetCost();
                _description = _menuItem.GetDescription();

                Console.WriteLine(Constants.AnyOtherChoice);
            }
        }
コード例 #3
0
ファイル: Chocolate.cs プロジェクト: Technopark95/CoffeeShop
 public override string GetDescription()
 {
     return(_beverageType.GetDescription() + " topped with Chocolate");
 }
コード例 #4
0
 public string GetDescription()
 {
     return(_beverage.GetDescription());
 }
コード例 #5
0
 private static void Display(IBeverage beverage)
 {
     Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost());
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: HaiAnhLe2910/Design-pattern
        private void btnOrder_Click(object sender, EventArgs e)
        {
            //Make myBeverage null.
            myBeverage = null;

            if (rbHouseBlend.Checked)
            {
                myBeverage = new HouseBlend();
            }
            else if (rbDecaf.Checked)
            {
                myBeverage = new Decaf();
            }
            else
            {
                myBeverage = new Expresso();
            }


            if (cbMilk.Checked)
            {
                int amountOFMilk = Convert.ToInt32(comboMilk.Text);

                for (int i = 0; i < amountOFMilk; i++)
                {
                    myBeverage = new Milk(myBeverage);
                }
                // Descrip = myBeverage.GetDescription() + " " + amountOFMilk;
            }

            if (cbMocha.Checked)
            {
                int amountOFMocha = Convert.ToInt32(comboMocha.Text);

                for (int i = 0; i < amountOFMocha; i++)
                {
                    myBeverage = new Mocha(myBeverage);
                }

                // Descrip = myBeverage.GetDescription() + " " + amountOFMocha;
            }

            if (cbSoy.Checked)
            {
                int amountOFSoy = Convert.ToInt32(comboSoy.Text);

                for (int i = 0; i < amountOFSoy; i++)
                {
                    myBeverage = new Soy(myBeverage);
                }

                //  Descrip = myBeverage.GetDescription() + " " + amountOFSoy;
            }

            if (cbWhip.Checked)
            {
                int amountOFWhip = Convert.ToInt32(comboWhip.Text);

                for (int i = 0; i < amountOFWhip; i++)
                {
                    myBeverage = new Whip(myBeverage);
                }

                //  Descrip = myBeverage.GetDescription() + " "+amountOFWhip;
            }


            tbPrice.Text = myBeverage.GetCost().ToString();


            tbDescription.Text = "You ordered : " + myBeverage.GetDescription() + '.';
        }
コード例 #7
0
 public string GetDescription() => beverage.GetDescription() + ", Whip";
コード例 #8
0
 public string GetDescription() => beverage.GetDescription() + ", Soy";
コード例 #9
0
 public string GetDescription() => beverage.GetDescription() + ", Mocha";
コード例 #10
0
ファイル: Honey.cs プロジェクト: Technopark95/CoffeeShop
 public override string GetDescription()
 {
     return(_beverageType.GetDescription() + " topped with Honey");
 }
コード例 #11
0
 public string GetDescription()
 {
     return(m_beverage.GetDescription() + ", " + GetCondimentDescription());
 }
コード例 #12
0
 public virtual string GetDescription()
 {
     return(Beverage.GetDescription());
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: egoshin-igor/OOD
 private static void PrintBeverageInfo(IBeverage beverage)
 {
     Console.WriteLine($"Beverage description: {beverage.GetDescription()}. Price: {beverage.GetCost()}");
 }
コード例 #14
0
 public string GetDescription()
 {
     return(beverage.GetDescription() + description);
 }
コード例 #15
0
 public string GetDescription()
 {
     return(string.Format("{0},{1}", beverage.GetDescription(), description));
 }
コード例 #16
0
 public string GetDescription()
 {
     return($"{_beverage.GetDescription()}, {GetCondimentDescription()}");
 }