Skip to content

Instantly share code, notes, and snippets.

@jasongorman

jasongorman/Room.java Secret

Created Apr 10, 2021
Embed
What would you like to do?
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