From ea99b984a7211a8c4dac851494a5c0e9c4a8a7ca Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Thu, 8 Feb 2024 21:48:47 +0100 Subject: [PATCH] Added validation check for operation id --- src/inputHandler.c | 6 ++++++ src/inputHandler.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/inputHandler.c b/src/inputHandler.c index 107b9df..0ecd1d6 100644 --- a/src/inputHandler.c +++ b/src/inputHandler.c @@ -1,4 +1,5 @@ #include "inputHandler.h" +#include int getOperationId(char symbol) { int id = 0; @@ -41,3 +42,8 @@ char getOperationSymbol(int id) { } return symbol; } + +int isOperationValid(int id) { + if(id < 0 || id > 7) return 0; + return 1; +} \ No newline at end of file diff --git a/src/inputHandler.h b/src/inputHandler.h index 98f1421..107f49e 100644 --- a/src/inputHandler.h +++ b/src/inputHandler.h @@ -5,4 +5,6 @@ int getOperationId(char); char getOperationSymbol(int); +int isOperationValid(int); + #endif //THEADMIRALS_INPUTHANDLER_H