using System;
class Rectangle
{
double width, height;
public void setVal()
{
width = 0;
height = 0;
}
public void setVal(double w, double h)
{
width = w;
height = h;
}
public void setVal(double len)
{
width = len;
height = len;
}
public double area()
{
return width * height;
}
}
using System;
class Program
{
public static void Main(String[] args)
{
Rectangle rec1 = new Rectangle();
Rectangle rec2 = new Rectangle();
Rectangle rec3 = new Rectangle();
rec1.setVal();
rec2.setVal(3.0, 7.0);
rec3.setVal(5.0);
Console.WriteLine("The area of rec1 is: " + rec1.area());
Console.WriteLine("The area of rec1 is: " + rec2.area());
Console.WriteLine("The area of rec1 is: " + rec3.area());
}
}
Method Overloading
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment