Esempio n. 1
0
        public void CadastrandoUmNovoJogo()
        {
            BaseDeDados dbXml = new BaseDeDados();
            Jogo jogo = new Jogo("Yugioh","duel cards",109.90,dbXml.nextID(),"locado");
            dbXml.cadastrarJogo(jogo);
            Jogo jogoEsperado = new Jogo("Yugioh", "duel cards", 109.90, 22, "locado");

            Assert.AreEqual(jogo, jogoEsperado);
        }
Esempio n. 2
0
        public static void CadastrarNovoJogo()
        {
            menuPrincipal.LimparTela();

            BaseDeDados dbXml = new BaseDeDados();

            string nomeJogo = "";
            double preco = 0.0;
            string categoria = "";
            string status = "";
            int id;
            bool primeiroLoop = true;
            bool rodando = true;
            bool loopCategoria = true;
            bool loopStatus = true;

            while (rodando)
            {

                menuPrincipal.PedirNomeDoJogo();
                nomeJogo = Console.ReadLine();

                if (nomeJogo != "")
                {
                    rodando = false;
                    while (primeiroLoop)
                    {

                        menuPrincipal.PedirPreco();
                        try
                        {
                            preco = Convert.ToDouble(Console.ReadLine());
                            primeiroLoop = false;
                        }
                        catch (FormatException)
                        {
                            primeiroLoop = true;
                            menuPrincipal.PedirParaDigitarValorDouble();
                        }

                    }

                    while (loopCategoria)
                    {
                        menuPrincipal.PedirCategoria();
                        categoria = Console.ReadLine();
                        if(categoria != "")
                        {
                            loopCategoria = false;
                        }
                        else
                        {
                            menuPrincipal.ExceptionDigitarCategoria();
                        }

                    }

                    while (loopStatus)
                    {
                        menuPrincipal.PedirStatus();
                        status = Console.ReadLine();

                        if(status.ToLower() == "disponivel" || status.ToLower() == "locado")
                        {
                            loopStatus = false;
                        }
                        else
                        {
                            menuPrincipal.ExceptionStatus();
                        }

                    }

                    id = dbXml.nextID();
                    Jogo jogo = new Jogo(nomeJogo, categoria, preco, id,  status);
                    dbXml.cadastrarJogo(jogo);
                }
                else
                {
                    menuPrincipal.LimparTela();
                    menuPrincipal.ExceptionDigitarNome();
                }

                menuPrincipal.LimparTela();

            }
        }
Esempio n. 3
0
        public static void EditarJogo(string jogoASerAlterado)
        {
            BaseDeDados dbXml = new BaseDeDados();

            bool rodando = true;
            string novoNome = "";
            double preco = 0.0;
            string categoria = "";
            string status = "";
            int id = dbXml.nextID();
            int respostaSeQuerMudarID = NAO;

            if (jogoASerAlterado != "")
            {

                while (rodando)
                {
                    menuPrincipal.PedirNomeDoJogo();
                    novoNome = Console.ReadLine();
                    if(novoNome != "")
                    {
                        rodando = false;
                    }
                    else
                    {
                        menuPrincipal.ExceptionDigitarNome();
                    }
                }

                rodando = true;
                while (rodando)
                {

                    try
                    {
                        menuPrincipal.PedirPreco();
                        preco = Convert.ToDouble(Console.ReadLine());
                        rodando = false;
                    }
                    catch (FormatException)
                    {
                        menuPrincipal.PedirParaDigitarValorDouble();
                    }

                }

                rodando = true;

                while (rodando)
                {
                    menuPrincipal.PerguntarSeQuerMudarOId();
                    try
                    {

                        respostaSeQuerMudarID = Convert.ToInt32(Console.ReadLine());
                        if(respostaSeQuerMudarID == 1 || respostaSeQuerMudarID == 2)
                        {
                            rodando = false;
                        }
                        else
                        {
                            throw new FormatException();
                        }

                    }
                    catch (FormatException)
                    {
                        menuPrincipal.ExcepitionSeQuermudarID();
                    }

                }

                rodando = true;

                if (respostaSeQuerMudarID == SIM)
                {
                    while (rodando)
                    {
                        menuPrincipal.PedirId();
                        try
                        {
                            id = Convert.ToInt32(Console.ReadLine());
                            rodando = false;
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Você deve digitar um numero inteiro");
                        }
                    }

                }
                else
                {
                    id = dbXml.GetIdJogo(jogoASerAlterado);
                }

                rodando = true;
                while (rodando)
                {
                    menuPrincipal.PedirCategoria();
                    categoria = Console.ReadLine();
                    if (categoria != "")
                    {
                        rodando = false;
                    }
                    else
                    {
                        menuPrincipal.ExceptionDigitarCategoria();
                    }
                }

                rodando = true;
                while (rodando)
                {
                    menuPrincipal.PedirStatus();
                    status = Console.ReadLine();

                    if (status.ToLower() == "disponivel" || status.ToLower() == "locado")
                    {
                        rodando = false;
                    }
                    else
                    {
                        menuPrincipal.ExceptionStatus();
                    }

                }

                Jogo jogo = new Jogo(novoNome, categoria, preco, id,status);

                dbXml.AlterarCamposDoJogo(jogo, jogoASerAlterado);
            }
        }