Exemplo n.º 1
0
 private bool TemNumero()    //verifica se há número na expressão
 {
     foreach (char possivelNumero in txtVisor.Text)
     {
         if (!Operacao.EhOperador(possivelNumero + ""))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
 private void btnFechaParenteses_Click(object sender, EventArgs e)   // Método de quando o ) é selecionado
 {
     if (!string.IsNullOrEmpty(txtVisor.Text) && txtVisor.Text[txtVisor.Text.Length - 1] != '.' && (txtVisor.Text[txtVisor.Text.Length - 1] == ')' || !Operacao.EhOperador(txtVisor.Text[txtVisor.Text.Length - 1] + "")))
     {
         txtVisor.Text += ((Button)sender).Text;
         jaTemVirgula   = false;
     }
 }
Exemplo n.º 3
0
 private void btnAbreParenteses_Click(object sender, EventArgs e)    // Método de quando o ( é selecionado
 {
     if (string.IsNullOrEmpty(txtVisor.Text) || (txtVisor.Text[txtVisor.Text.Length - 1] != ')' && Operacao.EhOperador(txtVisor.Text[txtVisor.Text.Length - 1].ToString()) && txtVisor.Text[txtVisor.Text.Length - 1] != '.'))
     {
         txtVisor.Text += ((Button)sender).Text;
         jaTemVirgula   = false;
     }
 }
Exemplo n.º 4
0
 private void btnMultiplicacaoDivisao_Click(object sender, EventArgs e) // Método de quando * ou / é selecionado
 {
     if (!string.IsNullOrEmpty(txtVisor.Text) && txtVisor.Text[txtVisor.Text.Length - 1] != '(' && (!Operacao.EhOperador(txtVisor.Text[txtVisor.Text.Length - 1].ToString()) || txtVisor.Text[txtVisor.Text.Length - 1] == ')') && txtVisor.Text[txtVisor.Text.Length - 1] != '.')
     {
         txtVisor.Text += ((Button)sender).Text;
         jaTemVirgula   = false;
     }
 }
Exemplo n.º 5
0
 private void btnAdicaoSubtracao_Click(object sender, EventArgs e)   // Método de quando + ou - é selecionado
 {
     if (string.IsNullOrEmpty(txtVisor.Text) || (txtVisor.Text[txtVisor.Text.Length - 1] == 'V' || txtVisor.Text[txtVisor.Text.Length - 1] == '(' || !Operacao.EhOperador(txtVisor.Text[txtVisor.Text.Length - 1].ToString()) && txtVisor.Text[txtVisor.Text.Length - 1] != '.'))
     {
         txtVisor.Text += ((Button)sender).Text;
         jaTemVirgula   = false;
     }
 }
Exemplo n.º 6
0
 private void btnPonto_Click(object sender, EventArgs e) // Método de quando o . é selecionado
 {
     if (txtVisor.Text != "" && !jaTemVirgula && txtVisor.Text[txtVisor.Text.Length - 1] != '.' && !Operacao.EhOperador(txtVisor.Text[txtVisor.Text.Length - 1] + ""))
     {
         txtVisor.Text += ".";
         jaTemVirgula   = true;
     }
 }