Android Open Source - MathApp Operator






From Project

Back to project page MathApp.

License

The source code is released under:

MIT License

If you think the Android project MathApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ie.lc.mathApp;
/*from   w w  w.ja  v  a2 s .  c o m*/




public enum Operator
{
  plus,
  minus,
  multiply,
  divide;
  
  
  
  
  
  public String toString() {
    switch (this) {
      case plus:     return "+";
      case minus:    return "?";
      case multiply: return "";
      case divide:   return "";
      default:       return "?";
    }
  }
  
  
  
  
  
  public static Operator random() {
    Operator[] vals = Operator.values();  
    return vals[ Util.randomIntRange(0, vals.length) ];
  }
  
  
  
  
  
  public double evaluate( double left, double right ) {
    switch (this) {
      case plus:     return left + right;
      case minus:    return left - right;
      case multiply: return left * right;
      case divide:   return left / right;
      default:       return Double.NaN;
    }
  }
}




Java Source Code List

ie.lc.mathApp.ActivityArithmetic.java
ie.lc.mathApp.ActivityCommonMenu.java
ie.lc.mathApp.ActivityGameBase.java
ie.lc.mathApp.ActivityScore.java
ie.lc.mathApp.ActivitySqrt.java
ie.lc.mathApp.ActivityWave.java
ie.lc.mathApp.CallbackThread.java
ie.lc.mathApp.Callback.java
ie.lc.mathApp.Geo.java
ie.lc.mathApp.Operator.java
ie.lc.mathApp.ScoreData.java
ie.lc.mathApp.Score.java
ie.lc.mathApp.SeekBarAdapter.java
ie.lc.mathApp.Storage.java
ie.lc.mathApp.TextWatcherAdapter.java
ie.lc.mathApp.Util.java
ie.lc.mathApp.Wave.java