コード例 #1
0
        public static void Main(string[] args)
        {
            // 有两辆车需要销售,一辆是普通轿车,而另一辆则是奔驰
            Vehicle vehicle = new Vehicle();
            Vehicle benz = new Benz();

            // 向普通销售询问这两辆车的折扣
            var seller = new Seller();
            Console.WriteLine("Seller Vehicle{0}", seller.GetDiscountRate(vehicle));
            Console.WriteLine("Seller Vehicle{0}", seller.GetDiscountRate(benz));

            // 向销售经理询问这两辆车的折扣
            var manager = new SellerManager();
            Console.WriteLine("SellerManager Vehicle{0}", manager.GetDiscountRate(vehicle));
            Console.WriteLine("SellerManager Vehicle{0}", manager.GetDiscountRate(benz));

            Console.Read();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            // 有两辆车需要销售,一辆是普通轿车,而另一辆则是奔驰
            Vehicle vehicle = new Vehicle();
            Vehicle benz    = new Benz();

            // 向普通销售询问这两辆车的折扣
            var seller = new Seller();

            Console.WriteLine("Seller Vehicle{0}", seller.GetDiscountRate(vehicle));
            Console.WriteLine("Seller Vehicle{0}", seller.GetDiscountRate(benz));

            // 向销售经理询问这两辆车的折扣
            var manager = new SellerManager();

            Console.WriteLine("SellerManager Vehicle{0}", manager.GetDiscountRate(vehicle));
            Console.WriteLine("SellerManager Vehicle{0}", manager.GetDiscountRate(benz));

            Console.Read();
        }