Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created May 9, 2021 09:50
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/156d1b895ccd30a2639c4f0480b9c5f0 to your computer and use it in GitHub Desktop.
Save jasongorman/156d1b895ccd30a2639c4f0480b9c5f0 to your computer and use it in GitHub Desktop.
public class CarpetQuote {
public double calculate(Shape shape,
double pricePerSqM,
double width,
double length,
double radius,
double side,
double a,
double b,
double height) {
double area = 0.0;
switch(shape){
case Rectangle:
area = width * length;
break;
case Circle:
area = Math.PI * radius * radius;
break;
case EquilateralTriangle:
area = (Math.sqrt(3)/4) * side * side;
break;
case Trapezium:
area = ((a + b) / 2) * height;
break;
}
return Math.ceil(area * pricePerSqM);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment