You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.2 KiB

  1. #include "inputHandler.h"
  2. #include <stdio.h>
  3. // return operation id for a specific symbol
  4. int getOperationIdBySymbol(char symbol) {
  5. int id = 0;
  6. switch (symbol) {
  7. case '+':
  8. return 1;
  9. case '-':
  10. return 2;
  11. case '/':
  12. return 3;
  13. case '*':
  14. return 4;
  15. case '^':
  16. return 5;
  17. case '%':
  18. return 6;
  19. case '!':
  20. return 7;
  21. }
  22. return id;
  23. }
  24. // returns operation symbol for a specific operation id
  25. char getOperationSymbolById(int id) {
  26. char symbol = ' ';
  27. switch (id) {
  28. case 1:
  29. return '+';
  30. case 2:
  31. return '-';
  32. case 3:
  33. return '/';
  34. case 4:
  35. return '*';
  36. case 5:
  37. return '^';
  38. case 6:
  39. return '%';
  40. case 7:
  41. return '!';
  42. }
  43. return symbol;
  44. }
  45. // Checking if operation id is available
  46. int isOperationIdValid(int id) {
  47. if(id < 1 || id > 7) return 0;
  48. return 1;
  49. }
  50. int isNumberTooBig(int number) {
  51. if(number < 200) return 0;
  52. //printf("This number is too big. Please choose a smaller one...\n");
  53. return 1;
  54. }