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.
58 lines
1.2 KiB
58 lines
1.2 KiB
#include "inputHandler.h"
|
|
#include <stdio.h>
|
|
|
|
// return operation id for a specific symbol
|
|
int getOperationIdBySymbol(char symbol) {
|
|
int id = 0;
|
|
switch (symbol) {
|
|
case '+':
|
|
return 1;
|
|
case '-':
|
|
return 2;
|
|
case '/':
|
|
return 3;
|
|
case '*':
|
|
return 4;
|
|
case '^':
|
|
return 5;
|
|
case '%':
|
|
return 6;
|
|
case '!':
|
|
return 7;
|
|
}
|
|
return id;
|
|
}
|
|
|
|
// returns operation symbol for a specific operation id
|
|
char getOperationSymbolById(int id) {
|
|
char symbol = ' ';
|
|
switch (id) {
|
|
case 1:
|
|
return '+';
|
|
case 2:
|
|
return '-';
|
|
case 3:
|
|
return '/';
|
|
case 4:
|
|
return '*';
|
|
case 5:
|
|
return '^';
|
|
case 6:
|
|
return '%';
|
|
case 7:
|
|
return '!';
|
|
}
|
|
return symbol;
|
|
}
|
|
|
|
// Checking if operation id is available
|
|
int isOperationIdValid(int id) {
|
|
if(id < 1 || id > 7) return 0;
|
|
return 1;
|
|
}
|
|
|
|
int isNumberTooBig(int number) {
|
|
if(number < 200) return 0;
|
|
//printf("This number is too big. Please choose a smaller one...\n");
|
|
return 1;
|
|
}
|