in my programming class in form
I have to show the area in a message, only that they want the data of height
and width
to get it from the inheritance of the class and in the way that the I'm doing it always returns zero in the value of the area
DEMONSTRATION OF THE CODE
/// RECTANGLE CLASS
class Rectangulo : PresentationObject
{
public int resultadoArea;
public int ResultadoArea
{
get
{
return this.resultadoArea;
}
set
{
this.resultadoArea = value;
}
}
public Rectangulo()
{
this.ResultadoArea = width * height;
}
}
//CLASE PRESENTATION OBJECT
class PresentationObject
{
public int width;
public int height;
public int Width
{
get
{
return this.width;
}
set
{
this.width = value;
}
}
public int Height
{
get
{
return this.height;
}
set
{
this.height = value;
}
}
public PresentationObject()
{
}
public PresentationObject(int width,int height)
{
this.Width = width;
this.Height = height;
}
}
///BOTON DONDE MUESTRA EL MENSAJE
private void btbCalcular_Click(object sender, EventArgs e)
{
Rectangulo rect = new Rectangulo();
MessageBox.Show("El area es: " + rect.resultadoArea , "Calcular Area", MessageBoxButtons.OK);
}