-
-
Save jasongorman/188dc6f2235c33bf52c0b02fa96ebf57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Room { | |
double area(); | |
} | |
public class RectangularRoom implements Room { | |
private final double width; | |
private final double length; | |
public RectangularRoom(double width, double length) { | |
this.width = width; | |
this.length = length; | |
} | |
@Override | |
public double area() { | |
return width * length; | |
} | |
} | |
public class CircularRoom implements Room { | |
private final double radius; | |
public CircularRoom(double radius) { | |
this.radius = radius; | |
} | |
@Override | |
public double area() { | |
return PI * Math.pow(radius, 2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment