20091216

PRACTICA 13.1CLASE LLAMADA RECTANGULO ( visual).


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication1
{
class rectangulo
{
double ancho, largo;
public rectangulo()
{
ancho = 0;
largo = 0;

}
public void Asignardatos(double w, double h)
{
ancho = w;
largo = h;

}
public void Asignarancho(double w)
{
ancho = w;

}
public void Asignarlargo(double h)
{
largo = h;
}
public double Obtenerancho()
{
return ancho;

}
public double Obtenerlargo()
{
return largo;
}
public double Area()
{
return largo * ancho;
}
public double Perimetro()
{
return 2 * (largo + ancho);

}


}
}
........................................................................................
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
textBox1.Focus();
double h, w;
rectangulo r1 = new rectangulo();
h = double.Parse(textBox1.Text);
w = double.Parse(textBox2.Text);
r1.Asignarancho(w);
r1.Asignarlargo(h);
textBox3.Text = ("El perimetro es = " + r1.Perimetro());
textBox4.Text = ("El areala es = " + r1.Area());

}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
}

private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}

No hay comentarios:

Publicar un comentario