示例#1
0
        private void btnListar_Click(object sender, EventArgs e)
        {
            try
            {
                string lista = "";
                Pilhas pAux  = new Pilhas();

                while (pilha.Size() > 0)
                {
                    lista += string.Format("Nome: {0}\nSalário: {1}\n\n",
                                           pilha.Peek().Name.ToString(),
                                           pilha.Peek().Salary.ToString());
                    pAux.Push(pilha.Pop());
                }
                while (pAux.Size() > 0)
                {
                    pilha.Push(pAux.Pop());
                }

                MessageBox.Show(lista);
            }
            catch (Exception error)
            {
                MessageBox.Show(string.Format("ERRO: {0}", error));
            }
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Pilhas pAux = new Pilhas();

            while (pilha.Size() > 1)
            {
                pAux.Push(pilha.Pop());
            }

            MessageBox.Show("Base Removida com sucesso!");

            while (pAux.Size() > 0)
            {
                pilha.Push(pAux.Pop());
            }
        }
示例#3
0
        private void btnSomar_Click(object sender, EventArgs e)
        {
            try
            {
                int    salario = 0;
                Pilhas pAux    = new Pilhas();

                while (pilha.Size() > 0)
                {
                    salario += pilha.Peek().Salary;
                    pAux.Push(pilha.Pop());
                }
                while (pAux.Size() > 0)
                {
                    pilha.Push(pAux.Pop());
                }

                MessageBox.Show(salario.ToString());
            }
            catch (Exception error)
            {
                MessageBox.Show(string.Format("ERRO: {0}", error));
            }
        }