Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("請輸入玩家人數");
            var playerAmount = Convert.ToInt32(Console.ReadLine());

            var playStation    = new PlayStation();
            var nintendoSwitch = new NintendoSwitch();

            var gameConsoles = new List <GameConsoleAbstract>()
            {
                playStation,
                nintendoSwitch,
            };

            gameConsoles.ForEach(x => ShowDetail(x, playerAmount));

            Console.WriteLine("將PS插入手把擴充器,連接網路讀取遊戲\n");

            playStation.SetGamePadTool(new ExpansionGamePad());
            playStation.SetLoadGameWay(new NetworkLoadGame());

            ShowDetail(playStation, playerAmount);

            Console.WriteLine("將NS連接網路讀取遊戲\n");
            nintendoSwitch.SetLoadGameWay(new NetworkLoadGame());

            ShowDetail(nintendoSwitch, playerAmount);

            Console.ReadKey();
        }
Example #2
0
    public static Gift CreateGift(string giftName)
    {
        Gift gift;

        switch (giftName)
        {
        case "Phone":
            var phone = new Phone(Phones.Count);

            Phones.Add(phone);
            gift = phone;
            break;

        case "PlayStation":
            var playStation = new PlayStation(PlayStations.Count);

            PlayStations.Add(playStation);
            gift = playStation;
            break;

        default:
            gift = null;
            break;
        }

        return(gift);
    }
Example #3
0
        //Methods

        public void LoadGame()
        {
            string playingOn = "";

            switch (GamingSystem)
            {
            case GamingSystem.PC:
                playingOn = PC.ToString();
                break;

            case GamingSystem.Nintendo:
                playingOn = Nintendo.ToString();
                break;

            case GamingSystem.PlayStation:
                playingOn = PlayStation.ToString();
                break;

            case GamingSystem.Xbox:
                playingOn = Xbox.ToString();
                break;

            case GamingSystem.Sega:
                playingOn = Sega.ToString();
                break;

            default:
                playingOn = "system that we are not sure about";
                break;
            }
            Console.WriteLine($"You have loaded the game on a {playingOn}.");
        }
Example #4
0
        /// <summary>
        /// Elimina una fila del DataTable
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnVender_Click(object sender, EventArgs e)
        {
            try
            {
                DataRowView fila = (DataRowView)dataGridView1.CurrentRow.DataBoundItem;

                int    id             = int.Parse(fila["id"].ToString());
                float  precio         = float.Parse(fila["precio"].ToString());
                string almacenamiento = fila["almacenamiento"].ToString();
                string lanzamiento    = fila["lanzamiento"].ToString();

                if (fila["modelo"].ToString() != "")
                {
                    int            modelo = int.Parse(fila["modelo"].ToString());
                    PlayStation    p      = new PlayStation(id, precio, ConvertirAEnum(almacenamiento), lanzamiento, modelo);
                    FrmPlayStation frm    = new FrmPlayStation(p);

                    if (this.EventoVender != null) // Si fue asociado, desasocio asi no se repite la accion mas de una vez
                    {
                        this.EventoVender -= psSeleccionado_EventoVender;
                    }
                    this.psSeleccionado = p;
                    this.EventoVender  += psSeleccionado_EventoVender; // Asocio el manejador al evento

                    frm.StartPosition = FormStartPosition.CenterScreen;

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        fila.Delete();
                        this.EventoVender(this, EventArgs.Empty); // Llamo al EventoVender
                    }
                }
                else
                {
                    float peso = float.Parse(fila["peso"].ToString());

                    VR v = new VR(id, precio, ConvertirAEnum(almacenamiento), lanzamiento, peso);

                    FrmVR frm = new FrmVR(v);

                    frm.StartPosition = FormStartPosition.CenterScreen;

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        fila.Delete();
                        MessageBox.Show($"Venta de: {v}\nSe imprimio el ticket!");

                        Thread tarea = new Thread(CargarFormularioGif); // Creo un nuevo hilo
                        tarea.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Completa los campos del form con la informacion de p
        /// </summary>
        /// <param name="p"></param>
        public FrmPlayStation(PlayStation p) : this()
        {
            this.p = p;

            this.txtId.Text             = this.p.Id.ToString();
            this.txtPrecio.Text         = p.Precio.ToString();
            this.cmbAlmacenamiento.Text = p.Almacenamiento.ToString();
            this.txtLanzamiento.Text    = p.Lanzamiento;
            this.cmbModelo.Text         = p.Modelo.ToString();
        }
Example #6
0
        public void ShouldShutdownConsole()
        {
            var playStation = new PlayStation();
            var remote      = new JoystickAdvanced(playStation);

            playStation.Startup();

            Assert.True(remote.ConectOnConsole());
            Assert.True(remote.ShutdownConsole());
        }
Example #7
0
        /// <summary>
        /// Modifica los datos del DataTable
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnModificar_Click(object sender, EventArgs e)
        {
            int i = this.dataGridView1.SelectedRows[0].Index;

            DataRow fila = this.dt.Rows[i];

            try
            {
                int    id             = int.Parse(fila["id"].ToString());
                float  precio         = float.Parse(fila["precio"].ToString());
                string almacenamiento = fila["almacenamiento"].ToString();
                string lanzamiento    = fila["lanzamiento"].ToString();

                if (fila["modelo"].ToString() != "") // Entonces es PlayStation
                {
                    int modelo = int.Parse(fila["modelo"].ToString());

                    PlayStation p = new PlayStation(id, precio, ConvertirAEnum(almacenamiento), lanzamiento, modelo);

                    FrmPlayStation frm = new FrmPlayStation(p);

                    frm.StartPosition = FormStartPosition.CenterScreen;

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        fila["precio"]         = frm.PlayStation.Precio;
                        fila["almacenamiento"] = frm.PlayStation.Almacenamiento;
                        fila["lanzamiento"]    = frm.PlayStation.Lanzamiento;
                        fila["modelo"]         = frm.PlayStation.Modelo;
                    }
                }
                else // Sino es VR
                {
                    float peso = float.Parse(fila["peso"].ToString());

                    VR v = new VR(id, precio, ConvertirAEnum(almacenamiento), lanzamiento, peso);

                    FrmVR frm = new FrmVR(v);

                    frm.StartPosition = FormStartPosition.CenterScreen;

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        fila["precio"]         = frm.VR.Precio;
                        fila["almacenamiento"] = frm.VR.Almacenamiento;
                        fila["lanzamiento"]    = frm.VR.Lanzamiento;
                        fila["peso"]           = frm.VR.Peso;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            var xbox = new XBox();

            xbox.Play();

            var playStation = new PlayStation();

            playStation.Play();

            var adapter = new ControllerAdapter();

            xbox.Play(adapter);
        }
Example #9
0
        static void Main(string[] args)
        {
            Venta <Sony> sinEspacio = new Venta <Sony>();
            Venta <Sony> productos  = new Venta <Sony>(4);

            PlayStation p1 = new PlayStation(1, 700, ECapacidad.TB1, "2020", 5);
            PlayStation p2 = new PlayStation(2, 800, ECapacidad.GB500, "2020", 5);
            VR          v1 = new VR(3, 300, ECapacidad.RAM1GB, "2016", 300);
            VR          v2 = new VR(4, 400, ECapacidad.RAM2GB, "2017", 320);
            VR          v3 = new VR(5, 400, ECapacidad.RAM3GB, "2018", 320);

            productos  -= p1; // Sin productos
            sinEspacio -= p1; // Sin capacidad

            productos += p1;
            productos += p2;
            productos += p1; // Repetido
            productos += v1;
            productos += v2;

            productos += v3; // Sin espacio


            Console.WriteLine(productos.ToString());
            Console.ReadLine();

            productos -= v2;
            productos -= p1;

            Console.WriteLine(productos.ToString());
            Console.ReadLine();

            string      path = Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + @"\SonyXml.log";
            List <Sony> lAux;

            productos.Serializar(path, productos.listaProductos);
            productos.Deserializar(path, out lAux);

            try
            {
                productos.Deserializar(@"\invalida.exe", out lAux); // Excepcion
            }
            catch (ArchivosException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Example #10
0
        public void ImprimirTicket()
        {
            try
            {
                bool        retValue = false;
                PlayStation p        = new PlayStation(1, 600, ECapacidad.TB1, "2020", 5);
                retValue = Tickets <PlayStation> .ImprimirTiket(p);

                Assert.IsTrue(retValue);
            }
            catch (Exception e)
            {
                throw new ArchivosException("Error al imprimir el ticket", e);
            }
        }
        public void InstanciarListaVentas()
        {
            try
            {
                PlayStation         PS    = new PlayStation();
                Venta <PlayStation> venta = new Venta <PlayStation>();

                venta.listaProductos.Add(PS);

                Assert.IsNotNull(venta.listaProductos);
            }
            catch (NullReferenceException)
            {
                Assert.Fail("No se pudo instanciar la lista de ventas");
            }
        }
        /// <summary>
        /// Crea un nuevo objeto de tipo PlayStation con la informacion del formulario
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            string id = this.txtId.Text;

            id = id == "" ? "0" : id;

            FrmStore f = new FrmStore();

            try
            {
                this.p = new PlayStation(int.Parse(id), float.Parse(this.txtPrecio.Text), f.ConvertirAEnum(this.cmbAlmacenamiento.Text), this.txtLanzamiento.Text, int.Parse(this.cmbModelo.Text));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }