예제 #1
0
        private void updatePurchaseInfo(string laptopName)
        {
            Info_label.Text = laptopBeingEdited.GetPrice().ToString();
            listbox_purchase_info.Items.Clear();
            string[] info = laptopName.Split('\n');

            foreach (string line in info)
            {
                listbox_purchase_info.Items.Add(line);
            }
        }
 virtual public int GetPrice()
 {
     return(laptop.GetPrice());
 }
예제 #3
0
        private static void FactoryPatternSample()
        {
            Console.WriteLine("--Sample Factory Pattern--");
            ILaptopCreator lc = new DellXpsConcreteCreator();
            ILaptop        l  = lc.GetLaptop("");

            Console.WriteLine("Selected laptop is " + l.GetName() + " with a  price of " + l.GetPrice());

            l = lc.GetLaptop("15");
            Console.WriteLine("Selected laptop is " + l.GetName() + " with a  price of " + l.GetPrice());

            lc = new DellGSeriesConcreteCreator();
            l  = lc.GetLaptop("");
            Console.WriteLine("Selected laptop is " + l.GetName() + " with a  price of " + l.GetPrice());

            l = lc.GetLaptop("5");
            Console.WriteLine("Selected laptop is " + l.GetName() + " with a  price of " + l.GetPrice());

            lc = new DellVostroConcreteCreator();
            l  = lc.GetLaptop("");
            Console.WriteLine("Selected laptop is " + l.GetName() + " with a  price of " + l.GetPrice());
        }