⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mathtool.java

📁 java servlet编程源码
💻 JAVA
字号:
import org.webmacro.*;


public class MathTool implements ContextTool {
  /**
    * A new tool object will be instantiated per-request by calling 
    * this method.  A ContextTool is effectively a factory used to 
    * create objects for use in templates.  Some tools may simply return
    * themselves from this method; others may instantiate new objects
    * to hold the per-request state.
    */
  public Object init(Context c) {
    return this;
  }

  public static int add(int x, int y) {
    return x + y;
  }

  public static int subtract(int x, int y) {
    return x - y;
  }

  public static int multiply(int x, int y) {
    return x * y;
  }

  public static int divide(int x, int y) {
    return x / y;
  }

  public static int mod(int x, int y) {
    return x % y;
  }

  public static boolean lessThan(int x, int y) {
    return (x < y);
  }

  public static boolean greaterThan(int x, int y) {
    return (x > y);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -