From c4280af27cbe6b40f799168fc18b94409c7b6b5f Mon Sep 17 00:00:00 2001 From: fdai7514 Date: Mon, 6 Feb 2023 22:27:23 +0100 Subject: [PATCH] refactoring: format the code by implementing new variables and important comments in displayMenuCalculator.c and displayMenuCalculator.h --- src/displayMenuCalculator.c | 37 ++++++++++++++++++++++--------------- src/displayMenuCalculator.h | 10 ++++++++-- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/src/displayMenuCalculator.c b/src/displayMenuCalculator.c index de2ad01..872c724 100644 --- a/src/displayMenuCalculator.c +++ b/src/displayMenuCalculator.c @@ -1,24 +1,31 @@ #include "displayMenuCalculator.h" + +// Note: +/* This Function may or may not be implemented in actual program, even if it is merged to the main branch. + If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ + int check() { -if(a == 1) -{ -return 1; -} + if(a == 1) + { + return 1; + } } + void displayMenuCalculator(char x) { -if(x == 'c') -{ -if(check() == 1) -{ -printf(" 1. Add\n"); -printf(" 2. Subtract\n"); -printf(" 3. Multiply\n"); -printf(" 4. Divide\n"); -printf(" 5. Factorial\n"); -} -} + if(x == 'c') + { + if(check() == 1) + { + printf(" %d. Add\n", operation1); + printf(" %d. Subtract\n", operation2); + printf(" %d. Multiply\n", operation3); + printf(" %d. Divide\n", operation4); + printf(" %d. Factorial\n", operation5); + } + } } + diff --git a/src/displayMenuCalculator.h b/src/displayMenuCalculator.h index 6b13c2b..1afbc55 100644 --- a/src/displayMenuCalculator.h +++ b/src/displayMenuCalculator.h @@ -3,8 +3,14 @@ #include #include -int check(); -const int a = 1; +int check(); //int check() is helpful for indirectly testing void displayMenuCalculator() +const int a = 1; // Variable for indirectly testing void displayMenuCalculator() void displayMenuCalculator(char x); +int operation1 = 1; +int operation2 = 2; +int operation3 = 3; +int operation4 = 4; +int operation5 = 5; + #endif // DISPLAYMENUCALCULATOR_H