thufir

what does ("+") mean?

Sep 15th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. // Enum type with constant-specific class bodies and data
  2. public enum Operation {
  3. PLUS("+") {
  4. double apply(double x, double y) { return x + y; }
  5. },
  6. MINUS("-") {
  7. double apply(double x, double y) { return x - y; }
  8. },
  9. TIMES("*") {
  10. double apply(double x, double y) { return x * y; }
  11. },
  12. DIVIDE("/") {
  13. double apply(double x, double y) { return x / y; }
  14. };
  15. private final String symbol;
  16. Operation(String symbol) { this.symbol = symbol; }
  17. @Override public String toString() { return symbol; }
  18. abstract double apply(double x, double y);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment