Java Reference
In-Depth Information
public double Area(int x, int y)
{
return (x * y);
}
}
//******************************************
// Circle class
//******************************************
class Circle
{
// Method Area()
public double Area(int x, int y)
{
return (3.1415 * (x * x));
}
}
//******************************************
// Window class
//******************************************
class Window
{
// Attributes in Window class
private int width;
private int height;
// Constructor for Window
public Window(int w, int h)
{
this.width = w;
this.height = h;
}
// First method WinArea()
public void WinArea(Rectangle rect)
{
double thisArea;
thisArea = rect.Area(this.width, this.height);
System.out.println("Area of this Window is: " + thisArea);
}
// Second method WinArea()
public void WinArea(Circle circ)
{
double thisArea;
thisArea = circ.Area(this.width, this.height);
System.out.println("Area of this Window is: " + thisArea);
}
}
//******************************************
//******************************************
//
Driving class
Search WWH ::




Custom Search