Guest User

Untitled

a guest
Jun 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. /**
  3. * Testing file for Polish Notation Calculator
  4. */
  5. require 'lib\cls\cls.LukasiewiczCalculator.php';
  6.  
  7. use \lib\cls\LukasiewiczCalculator;
  8.  
  9. $pnc = new LukasiewiczCalculator();
  10.  
  11. echo '<h1><u>Polish Notation (PN) Calculator :</u></h1><p/>';
  12.  
  13. echo '<h3>==> Error PN Tests :</h3><ul>';
  14.  
  15. #
  16. # Set error expressions to test
  17. #
  18. $error_expressions = [
  19. '+1 7',
  20. '1 *-7',
  21. 'as17 / ',
  22. '',
  23. '1 7',
  24. '+ - * //',
  25. ];
  26.  
  27. #
  28. # Call Calculate function against error expressions and print results
  29. #
  30. foreach($error_expressions as $expression)
  31. {
  32. echo "<li>$expression : " . $pnc->Calculate($expression) . '</li>';
  33. }
  34.  
  35. echo '</ul><p/><br/>';
  36.  
  37. echo '<h3>==> Valid PN Tests :</h3><ul>';
  38.  
  39. #
  40. # Set valid expressions to calculate
  41. #
  42. $valid_expressions = [
  43. '+ 1 1', # 2
  44. '+ 9 * 2 6', # 21
  45. '* 3 + 4 5', # 27
  46. '- * / 15 - 7 + 1 1 3 + 2 + 1 1', # 5
  47. '* + 8 6 - + 1 2 3', # 0
  48. ];
  49.  
  50. #
  51. # Call Calculate function against valid expressions and print results
  52. #
  53. foreach($valid_expressions as $expression)
  54. {
  55. echo "<li>$expression : <b style=\"margin-left: 1em; color: blue\">" . $pnc->Calculate($expression) . '</b></li><br/>';
  56. }
  57.  
  58. echo '</ul><p/>';
  59.  
  60. exit;
Add Comment
Please, Sign In to add comment