2
2
3
3
class MainClass {
4
4
public static void Main ( string [ ] args ) {
5
- string [ ] allowedOperations = { "1" , "2" , "3" , "4" , "5" } ;
6
- convertor Con = new convertor ( ) ;
7
- string cis1 , cis2 , op ;
8
- float vys = 0 , c1 = 0 , c2 = 0 ;
9
- int o = 0 ;
10
- Console . WriteLine ( "Calculator v00nic" ) ;
11
- Console . Write ( "Type first number: " ) ;
12
- cis1 = Console . ReadLine ( ) ;
13
- Console . Write ( "Type second number: " ) ;
14
- cis2 = Console . ReadLine ( ) ;
15
- Con . stringCheck ( cis1 , cis2 , args ) ;
16
- c1 = float . Parse ( cis1 ) ;
17
- c2 = float . Parse ( cis2 ) ;
18
- Console . WriteLine ( "now select Operation: 1-+, 2 - -, 3 - *, 4 - /" ) ;
19
- op = Console . ReadLine ( ) ;
20
-
5
+ string [ ] caughtErrors = new string [ 3 ] ; //something to not get warnings
6
+ convertor Con = new convertor ( ) ; //convertor class, which contains methods not meeting the software purpose
7
+ string cis1 , cis2 , op ; //dem stringz
8
+ float vys = 0 , c1 = 0 , c2 = 0 ; //dem floatz
9
+ int o = 0 ; //Operation
10
+ Console . WriteLine ( "Calculator v00nic" ) ; //Don't mind me
11
+ Console . Write ( "Type first number: " ) ; //i'm just
12
+ cis1 = Console . ReadLine ( ) ; //reads value from dat Console
13
+ Console . Write ( "Type second number: " ) ; //printing to console
14
+ cis2 = Console . ReadLine ( ) ; //reads value from dat Console
15
+ try {
16
+ c1 = float . Parse ( cis1 ) ;
17
+ c2 = float . Parse ( cis2 ) ;
18
+ }
19
+ catch ( System . FormatException e ) {
20
+ caughtErrors [ 1 ] = e . ToString ( ) ;
21
+ Console . WriteLine ( "Oops! Wrong input format of number input! Preforming restart" ) ;
22
+ Main ( args ) ;
23
+ } //try to parse inserted value. if catches "System.FormatException" exception, calls the method to avoid crashing
24
+ Console . Write ( "now select Operation: 1-+, 2 - -, 3 - *, 4 - /, 5 - ^" ) ;
25
+ op = Console . ReadLine ( ) ; //reads value fromm dat Console
21
26
try {
22
27
o = int . Parse ( op ) ;
23
28
}
24
29
catch ( System . FormatException e ) {
30
+ caughtErrors [ 2 ] = e . ToString ( ) ;
25
31
o = 999 ;
26
- }
32
+ } //tries to parse operation, if cathes "System.FormatException" exceptions, makes steps to safely reload the method
27
33
switch ( o ) {
28
34
case 1 : vys = c1 + c2 ; break ;
29
35
case 2 : vys = c1 - c2 ; break ;
@@ -33,8 +39,8 @@ public static void Main (string[] args) {
33
39
case 999 : Console . WriteLine ( "Sorry, but you inserted invalid value of operation, preforming a quick restart!" ) ;
34
40
Main ( args ) ;
35
41
break ;
36
- }
37
- Console . WriteLine ( "I have Counted this: " + vys . ToString ( ) ) ;
42
+ } //main operation handler
43
+ Console . WriteLine ( "I have Counted this: " + vys . ToString ( ) ) ; //print the final vlue
38
44
39
45
Console . WriteLine ( "Do You wish to continue?" ) ;
40
46
Console . Write ( "(Y/N)" ) ;
@@ -47,8 +53,7 @@ public static void Main (string[] args) {
47
53
} else {
48
54
Console . WriteLine ( "Unexpected error" ) ;
49
55
Environment . Exit ( 1 ) ;
50
- }
51
-
56
+ } //handles if should restart to continue method Y = yes, N = No, anythong else = crash;
52
57
}
53
-
54
- }
58
+ }
59
+ //created by github.com/mineikCZ in 2018 (c)
0 commit comments