using System;
class Rectangle
{
double height, width;
public Rectangle()
{
height = 0;
width = 0;
}
public Rectangle(double height, double width)
{
this.height = height;
this.width = width;
}
public Rectangle(double len)
{
height = len;
width = len;
}
public double area()
{
return width * height;
}
}
using System;
class Program
{
public static void Main(String[] args)
{
Rectangle rec = new Rectangle();
Rectangle rec2 = new Rectangle(3.0, 7.5);
Rectangle rec3 = new Rectangle(5.0);
Console.WriteLine("The area of the Rectangle is: " + rec.area());
Console.WriteLine("The area of the Rectangle is: " + rec2.area());
Console.WriteLine("The area of the Rectangle is: " + rec3.area());
}
}
Using "this" keyword
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment