using System;
class Rectangle
{
double width, height;
public Rectangle()
{
width = 0;
height = 0;
}
public Rectangle(double w, double h)
{
width = w;
height = h;
}
public Rectangle(double len)
{
width = len;
height = 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());
}
}
Overloading Constructors
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment