RectangleB.java class:
public class RectangleB {
private double myHeight;
private double myWidth;
public RectangleB (double height, double width) {
myHeight = height;
myWidth = width;
}
public double GetHeight() {
return myHeight;
}
public double GetWidth() {
return myWidth;
}
public double GetArea() {
return myWidth*myHeight;
}
public double GetPerimeter() {
return 2*(myWidth + myHeight);
}
}
RectangleBMain.java:
public class RectangleBMain {
/**
* Constructor.
*/
public RectangleBMain () {
}
public static void main(String args[]) {
RectangleB aRect = new RectangleB(5.0, 2.0);
System.out.println("The rectangle has a perimeter of " + aRect.GetPerimeter());
System.out.println("The rectangle has an area of " + aRect.GetArea());
}
}