Skip to content

Commit 869bc03

Browse files
author
[FacuFalcone]
committed
Update the main.
1 parent 007359c commit 869bc03

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

Main.py

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23+
import os
2324
from Permutation import Permutations as P
2425
from Combination import Combinations as C
2526
from Variation import Variations as V
@@ -39,25 +40,50 @@ def SelectOperation(option: int):
3940
V.CompoundVariation()
4041
elif option == 6:
4142
C.CompoundCombinatory()
43+
else:
44+
print("Invalid option selected, please try again.")
4245
except Exception as e:
4346
print(f"Error: {e}")
4447

45-
46-
def CombinatorialCalculus():
47-
appName = "Combinatorial Calculus"
48-
version = "v1.2.0"
49-
author = "Facu Falcone"
48+
def PrintMenu()->int:
49+
"""
50+
Prints in console the menu of the app.
51+
"""
52+
option = 0
5053
print("Select an option from the ones below")
5154
print("1 - Simple Permutation.\n2 - Simple Variation.\n3 - Simple Combination.")
5255
print("4 - Compound Permutation.\n5 - Compound Variation.\n6 - Compound Combination.")
5356
try:
5457
option = int(input("Your option: "))
55-
SelectOperation(option)
56-
exit = input("\nExecution finished, please press a key to close the program...")
5758
except Exception as e:
5859
print(f"Error: {e}")
5960
finally:
61+
return option
62+
63+
def CleanScreen():
64+
"""
65+
Cleans the screen.
66+
"""
67+
return lambda: os.system('cls')
68+
69+
def CombinatorialCalculus():
70+
appName = "Combinatorial Calculus"
71+
version = "v1.2.0"
72+
author = "Facu Falcone"
73+
continueExec = "y"
74+
75+
while continueExec=='y':
6076
print(f"\n## {appName} {version} by {author}. ##\n")
77+
print("#################################")
78+
79+
option = PrintMenu()
80+
SelectOperation(option)
81+
82+
print("#################################")
83+
continueExec = input("\nWrite Y to do another calculus or N to close the app: ")
84+
continueExec = continueExec.lower()
85+
CleanScreen()
86+
6187

6288

6389
if __name__ == '__main__':

0 commit comments

Comments
 (0)