Exemplo n.º 1
0
        private void btnCount_Click(object sender, EventArgs e)
        {
            FrmCount  a;
            DetectAbc det;
            int       totUpper = 0;
            int       totLower = 0;
            string    txt;
            double    prom;

            txt = txtSentence.Text.Trim();
            if (txt.Length == 0)
            {
                MessageBox.Show("Error: Debes ingresar una oracion.");
                return;
            }
            a   = new FrmCount();
            det = new DetectAbc();
            det.RecSentence(txtSentence.Text);
            a.ShowChars(det);

            prom = det.ShowCounts(ref totLower, ref totUpper);
            txt  = "Promedio: " + prom;
            a.setLblProm(txt);

            txt = "Mayusculas: " + totUpper;
            a.setLblUpper(txt);

            txt = "Minusculas: " + totLower;
            a.setLblLower(txt);

            a.ShowDialog();
        }
Exemplo n.º 2
0
        public void ShowChars(DetectAbc da)
        {
            StringBuilder txt = new StringBuilder();

            for (int i = 0; i != 26; ++i)
            {
                if (da.Alpha.CountUpper[i] != 0)
                {
                    txt.Append("-> ").Append(da.Alpha.Abc[i]).Append(" : ").Append(da.Alpha.CountUpper[i]).Append("\r\n");
                }

                if (da.Alpha.CountLower[i] != 0)
                {
                    txt.Append("-> ").Append((char)(da.Alpha.Abc[i] + 32)).Append(" : ").Append(da.Alpha.CountLower[i]).Append("\r\n");
                }
            }
            txtCount.Text = txt.ToString();
        }