Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created April 10, 2021 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/188dc6f2235c33bf52c0b02fa96ebf57 to your computer and use it in GitHub Desktop.
Save jasongorman/188dc6f2235c33bf52c0b02fa96ebf57 to your computer and use it in GitHub Desktop.
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