Example #1
0
            static void Main()
            {
                double           saleAmount;
                char             code;
                DiscountDelegate firstDel, secondDel;

                firstDel = new DiscountDelegate(StandardDiscount);

                secondDel = new DiscountDelegate(PreferredDiscount);

                Write("Enter amount of sale");
                saleAmount = Convert.ToDouble(ReadLine());
                Write("Enter S for standard discount,"
                      + "or P for preferred discount.");
                code = Convert.ToChar(ReadLine());
                if (code == 'S')
                {
                    firstDel(ref saleAmount);
                }
                else
                {
                    secondDel(ref saleAmount);
                }
                WriteLine("New sale amount is {0}", saleAmount.ToString("C2"));
                ReadLine();//Necessary to keep console from exiting immediately.
            }
Example #2
0
        static void Main(string[] args)
        {
            double           saleAmount;
            char             code;
            DiscountDelegate firstDel, secondDel, thirdDel;

            firstDel  = new DiscountDelegate(StandardDiscount);
            secondDel = new DiscountDelegate(PreferredDiscount);

            thirdDel  = firstDel;
            thirdDel += secondDel;

            Console.WriteLine("Enter amount of sale: ");
            saleAmount = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter S for standard discount or P for the preferred discount " +
                              "\nor X for Xtreme discount: ");

            code = Convert.ToChar(Console.ReadLine());

            if (code == 'S')
            {
                firstDel(ref saleAmount);
            }
            else
            if (code == 'P')
            {
                secondDel(ref saleAmount);
            }
            else
            {
                thirdDel(ref saleAmount);
            }

            Console.WriteLine("New sale amount is {0}", saleAmount.ToString("C2"));
        }
 static void Main()
 {
     double saleAmount;
     char code;
     DiscountDelegate firstDel, secondDel;
     firstDel = new DiscountDelegate(StandardDiscount);
     secondDel = new DiscountDelegate(PreferredDiscount);
     Console.Write("Enter amount of sale ");
     saleAmount = Convert.ToDouble(Console.ReadLine());
     Console.Write("Enter S for standard discount, or P for preferred discount ");
     code = Convert.ToChar(Console.ReadLine());
     if (code == 'S')
         firstDel(ref saleAmount);
     else
         secondDel(ref saleAmount);
     Console.WriteLine("New sale amount is {0}", saleAmount.ToString("C2"));
 }
Example #4
0
        static void Main(string[] args)
        {
            double           saleAmount;
            char             code;
            DiscountDelegate firstDel, secondDel;

            firstDel  = new DiscountDelegate(StandardDiscount);
            secondDel = new DiscountDelegate(PrefferedDiscount);

            Write("Enter the amount of sale: ");
            saleAmount = Convert.ToDouble(ReadLine());
            Write("Enter S for standard discount , or P for preferred discount: ");
            code = Convert.ToChar(ReadLine());
            if (code == 'S')
            {
                firstDel(ref saleAmount);
            }
            else
            {
                secondDel(ref saleAmount);
            }
            WriteLine("New sale amount is {0}", saleAmount.ToString("C2"));
        }
        static void Main(string[] args)
        {
            DiscountDelegate first_del, second_del;

            first_del  = new DiscountDelegate(StandardDiscount);
            second_del = new DiscountDelegate(PreferredDiscount);

            Console.Write("Enter amount of sale ");
            double sale_amount = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter S for standard discount, or P for preferred discount ");
            char code = Convert.ToChar(Console.ReadLine());

            if (code == 'S')
            {
                first_del(ref sale_amount);
            }
            else
            {
                second_del(ref sale_amount);
            }
            Console.WriteLine("New sale amount is {0}", sale_amount.ToString("C2"));
        }