fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public class Expression {
  11. private String textExpression = "";
  12. public Double[] args = {null, null};
  13. public char operation;
  14.  
  15. // Тут опущен код сеттеров и некоторых операций
  16. }
  17.  
  18. public static void main (String[] args) throws java.lang.Exception
  19. {
  20. // your code goes here
  21. }
  22.  
  23. /**
  24.   * Обработка простых операций +,-,*,/
  25.   * @return
  26.   */
  27. public Double simpleOperation(Expression expr) {
  28. double result = Double.NaN;
  29. switch (expr.operation) {
  30. case '+':
  31. result = expr.args[0] + expr.args[1];
  32. case '-':
  33. result = expr.args[0] - expr.args[1];
  34. case '*':
  35. result = expr.args[0] * expr.args[1];
  36. case '/':
  37. result = expr.args[0] / expr.args[1];
  38. default:
  39. // В Яве так делать нельзя
  40. // result = null;
  41. }
  42. return result;
  43. }
  44. }
Success #stdin #stdout 0.12s 46844KB
stdin
Standard input is empty
stdout
Standard output is empty