Hi all,
A question asks me to write overloading functions to square,circle ,rectangle and triangle....
But since the square and circle have only one parameter I had to change the parameter of area of circle to double......
Is this the only way to accomplish this.....
Are there any other ways of writing it with out this kind of cheating....
public class ShapeArea{
public static int Area(int sideLength){
return Area(sideLength,sideLength);
}
public static int Area(int sideA,int sideB){
return sideA*sideB;
}
public static double Area(double r){
return Math.PI*r*r;
}
public static void main(String cmd[]){
System.out.println(Area(5.0));
}
}
Please suggest me towards a good decision....
Thanks in advance!