コード例 #1
0
 public FormTablet(ITablet t)
 {
     StartPosition = FormStartPosition.CenterScreen;
     InitializeComponent();
     pictureBox1.Image = t.ShowPictureHD();
     Show();
 }
コード例 #2
0
        static void Main(string[] args)
        {
            // HR New Employee Process

            IDeviceFactory factory = new SamsungFactory();

            IMobilePhone phone = factory.CreateMobilePhone();

            phone.Call("+45 12345678");

            ITablet tablet = factory.CreateTablet();

            tablet.PowerOn();
            tablet.PowerOff();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: wincubate/agilent
        static void Main(string[] args)
        {
            // HR New Employee Process

            IDeviceFactory factory = new AppleFactory(); // <-- Only(!) reference to vendor

            IMobilePhone phone = factory.CreateMobilePhone();

            phone.Call("+45 12345678");

            ITablet tablet = factory.CreateTablet();

            tablet.PowerOn();
            tablet.PowerOff();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Zgencheva/C--OOP
        static void Main(string[] args)
        {
            Console.WriteLine("Are you an apple fangirl?");
            var isFangirl = Console.ReadLine() == "yes" ? true : false;
            ITechnologyAbstractFactory techFactory = null;

            if (isFangirl)
            {
                techFactory = new AppleFactory();
            }
            else
            {
                techFactory = new SamsungFactory();
            }
            IMobilePhone myphone  = techFactory.CreatePhone();
            ITablet      mytablet = techFactory.CreateTablet();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: KamenYu/Csharp-Advanced
        static void Main(string[] args)
        {
            string techType = Console.ReadLine();

            ITechnologyAbstractFactory abstractFactory = null;

            if (techType.ToLower() == "samsung")
            {
                abstractFactory = new SamsungFactory();
            }
            else if (techType.ToLower() == "apple")
            {
                abstractFactory = new AppleFactory();
            }

            IMobilePhone mobilePhone = abstractFactory.CreatePhone();
            ITablet      tablet      = abstractFactory.CreateTablet();

            Console.WriteLine(mobilePhone.GetType().Name);
            Console.WriteLine(tablet.GetType().Name);
        }
コード例 #6
0
        /// <summary>
        /// Shows all workplace equipment of the company.
        /// </summary>
        /// <param name="company">Company.</param>
        static void ShowWorkplaceEquipment(Company company)
        {
            IWorkplaceEquipmentFactory workplaceEquipmentFactory = WorkplaceEquipmentFactories.GetFactory(company);

            if (workplaceEquipmentFactory == null)
            {
                Console.WriteLine("{0} company did not provide any information about workplace equipments.\n", company);
                return;
            }

            Console.WriteLine("{0} workplace equipments:\n", company);

            IMouse mouse = workplaceEquipmentFactory.GetMouse();

            Console.WriteLine(mouse);

            ILaptop laptop = workplaceEquipmentFactory.GetLaptop();

            Console.WriteLine(laptop);

            ITablet tablet = workplaceEquipmentFactory.GetTablet();

            Console.WriteLine(tablet);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            int    iProveedor = 0, iProducto = 0;
            double dCantidad = 0;
            string cProveedor = string.Empty;
            string cRequisicion = string.Empty, cCotizacion = string.Empty;
            double dPrecio = 0, dIva = 0;

            IProductosFactory svrProductosFactory = null;
            ILaptop           svrLaptop           = null;
            ITablet           svrTablet           = null;


            Console.WriteLine("**** Sistema de Compras *****");
            Console.WriteLine("Proporcione el NÚMERO que corresponde al Proveedor:");
            Console.WriteLine("HP: 1");
            Console.WriteLine("DELL: 2");
            int.TryParse(Console.ReadLine(), out iProveedor);
            Console.WriteLine("Proporcione el NÚMERO que corresponde al Producto:");
            Console.WriteLine("LAPTOP: 1");
            Console.WriteLine("TABLET: 2");
            int.TryParse(Console.ReadLine(), out iProducto);
            Console.WriteLine("Proporcione la cantidad del Producto");
            double.TryParse(Console.ReadLine(), out dCantidad);


            switch (iProveedor)
            {
            case 1:
                svrProductosFactory = new CreadorProdcutosHP();
                cProveedor          = "HP";
                dPrecio             = 5700;
                dIva = 16;
                break;

            case 2:
                svrProductosFactory = new CreadorProductosDEL();
                cProveedor          = "DELL";
                dPrecio             = 6150;
                dIva = 15;
                break;

            default:
                Console.WriteLine("Indique un Proveedor correcto");
                break;
            }

            if (svrProductosFactory != null)
            {
                switch (iProducto)
                {
                case 1:
                    svrLaptop    = svrProductosFactory.CrearLaptop();
                    cRequisicion = svrLaptop.GeneraRequisicion(dCantidad, cProveedor);
                    cCotizacion  = svrLaptop.GeneraCotizacion(dCantidad, dPrecio, dIva);
                    break;

                case 2:
                    svrTablet    = svrProductosFactory.CrearTablet();
                    cRequisicion = svrTablet.GeneraRequisicion(dCantidad, cProveedor);
                    cCotizacion  = svrTablet.GeneraCotizacion(dCantidad, dPrecio, dIva);
                    break;

                default:
                    Console.WriteLine("Indique un Producto correcto");
                    break;
                }

                Console.WriteLine(cRequisicion);
                Console.WriteLine(cCotizacion);
            }

            Console.Write("Presiona cualquier tecla para salir del programa...");
            Console.ReadKey();
        }