Esempio n. 1
0
        static void Main(string[] args)
        {
            //Refer Coffee Shop class diagram

            #region Somedescription
            Console.WriteLine("Welcome to Starbuzz Coffee");
            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("We usually do care about customers,");
            Console.WriteLine("But profit is more important to us.");
            Console.WriteLine("So today due to excessive amount of orders,");
            Console.WriteLine("We would not cater to your needs and show you what programmer decides");
            Console.WriteLine("Yes you read it right the programmer not the barista");
            Console.WriteLine("");
            #endregion

            #region PatternImplementation
            Beverage beverage = new Espresso();
            Console.WriteLine(beverage.getDescription() + " "
                              + beverage.cost() + "$");

            /*In the code example below and above we have used Liskov Substitution principle just a fancy name
             * for saying the thing that inherited class can be substituted for the parent class like we use
             * Beverage but create espresso object*/


            Beverage beverage2 = new Espresso();
            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);

            // The above order translates to one espresso with two shots of mocha. Silly order :)


            Console.WriteLine(beverage2.getDescription() + " "
                              + beverage2.cost() + "$");
            #endregion

            #region EndDescription
            Console.WriteLine("");
            Console.WriteLine("Thank you for your time at StarBuzz");
            Console.WriteLine("We added above both orders even if you don't wanna drink");
            Console.WriteLine("Warning: It's not free either");
            Console.WriteLine("Our Programmer is our Barista");
            #endregion

            Console.ReadLine();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine(beverage.Description + " $" + beverage.Cost());

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine(beverage2.Description + " $" + beverage2.Cost());

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine(beverage3.Description + " $" + beverage3.Cost());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Beverage beverage = new Espresso();

            Console.WriteLine(string.Format("{0} ${1}", beverage.GetDescription(), beverage.Cost()));

            Beverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);

            Console.WriteLine(string.Format("{0} ${1}", beverage2.GetDescription(), beverage2.Cost()));

            Beverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);

            Console.WriteLine(string.Format("{0} ${1}", beverage3.GetDescription(), beverage3.Cost()));
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            IBaverage espresso = new Espresso();

            Console.WriteLine($"{espresso.Name()} = ${espresso.Cost()}");
            Console.WriteLine("------------------------------------------------------------------");
            IBaverage houseBlend = new HouseBlend();

            Console.WriteLine($"{houseBlend.Name()} = ${houseBlend.Cost()}");
            Console.WriteLine("------------------------------------------------------------------");
            IBaverage houseBlendWithMocha = new HouseBlend();

            houseBlendWithMocha = new Mocha(houseBlendWithMocha);
            Console.WriteLine($"{houseBlendWithMocha.Name()} = ${houseBlendWithMocha.Cost()}");
            Console.WriteLine("------------------------------------------------------------------");
            IBaverage darkRosatedWithMochaAndSteamedMilk = new DarkRoast();

            darkRosatedWithMochaAndSteamedMilk = new Mocha(darkRosatedWithMochaAndSteamedMilk);
            darkRosatedWithMochaAndSteamedMilk = new SteamedMilk(darkRosatedWithMochaAndSteamedMilk);
            Console.WriteLine($"{darkRosatedWithMochaAndSteamedMilk.Name()} = ${darkRosatedWithMochaAndSteamedMilk.Cost()}");
            Console.WriteLine("------------------------------------------------------------------");
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            AbstractBeverage beverage = new Espresso();

            Console.WriteLine($"{beverage.Description} ${beverage.Cost / 100f :N2}");

            AbstractBeverage beverage2 = new DarkRoast();

            beverage2 = new Mocha(beverage2);
            beverage2 = new Mocha(beverage2);
            beverage2 = new Whip(beverage2);
            Console.WriteLine($"{beverage2.Description} ${beverage2.Cost / 100f :N2}");

            AbstractBeverage beverage3 = new HouseBlend();

            beverage3 = new Soy(beverage3);
            beverage3 = new Mocha(beverage3);
            beverage3 = new Whip(beverage3);
            Console.WriteLine($"{beverage3.Description} ${beverage3.Cost / 100f :N2}");

            Console.WriteLine("Press any key to continue . . .");
            Console.ReadKey();
        }
Esempio n. 6
0
        private static void PrintEspresso()
        {
            Beverage beverage = new Espresso();

            Console.Out.WriteLine(beverage);
        }
Esempio n. 7
0
 private static void PrintEspresso()
 {
     Beverage beverage = new Espresso();
     Console.Out.WriteLine(beverage);
 }