[ Foro de C# ]
using Calculadora_básica.Operaciones;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//Codigo creado por
namespace Calculadora_básica
{
public partial class Form1 : Form
{
double N1;
double N2;
string operacion;
public Form1()
{
InitializeComponent();
}
Operaciones.ClsSuma obj1 = new Operaciones.ClsSuma();
Operaciones.ClsResta obj2 = new Operaciones.ClsResta();
Operaciones.ClsMultiplicacion obj3 = new Operaciones.ClsMultiplicacion();
Operaciones.ClsDivision obj4 = new Operaciones.ClsDivision();
private double Division;
private void btn0_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "0";
}
private void btn1_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "1";
}
private void btn2_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "2";
}
private void btn3_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "3";
}
private void btn4_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "4";
}
private void btn5_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "5";
}
private void btn6_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "6";
}
private void btn7_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "7";
}
private void btn8_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "8";
}
private void btn9_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + "9";
}
private void btnPunto_Click(object sender, EventArgs e)
{
Pantalla.Text = Pantalla.Text + ".";
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnSuma_Click(object sender, EventArgs e)
{
operacion = "+";
N1 = double.Parse(Pantalla.Text);
Pantalla.Clear();
}
private void btnResta_Click(object sender, EventArgs e)
{
operacion = "-";
N1 = double.Parse(Pantalla.Text);
Pantalla.Clear();
}
private void btnMultiplicación_Click(object sender, EventArgs e)
{
operacion = "*";
N1 = double.Parse(Pantalla.Text);
Pantalla.Clear();
}
private void btnDivisión_Click(object sender, EventArgs e)
{
operacion = "/";
N1 = double.Parse(Pantalla.Text);
Pantalla.Clear();
}
private void btnIgual_Click(object sender, EventArgs e)
{
N2 = double.Parse(Pantalla.Text);
double Suma;
double Resta;
double Multiplicacion;
double Division;
switch (operacion)
{
case "+":
Suma = obj1.Sumar((N1), (N2));
Pantalla.Text = Suma.ToString();
break;
case "-":
Resta = obj2.Restar((N1), (N2));
Pantalla.Text = Resta.ToString();
break;
case "*":
Multiplicacion = obj3.Multiplicacion((N1), (N2));
Pantalla.Text = Multiplicacion.ToString();
break;
case "/":
Division = obj4.Division((N1), (N2));
Pantalla.Text = Division.ToString();
break;
}
}
private void btnBorrar_Click(object sender, EventArgs e)
{
Pantalla.Clear();
}
private void eliminar_Click(object sender, EventArgs e)
{
if (Pantalla.Text.Length == 1)
Pantalla.Text = "";
else
Pantalla.Text = Pantalla.Text.Substring(0, Pantalla.Text.Length - 1);
}
}
}