1 import eprog.*;
2
3 class TestBerechner {
4
5 public static void getEinheit(String s) {
6 try {
7 EprogIO.print(s + " ==> ");
8 EprogIO.println(Berechner.getEinheit(s));
9 } catch(Exception e) {
10 EprogIO.println("Exception: "+e);
11 }
12 }
13
14
15 public static void getDimension(String s) {
16 try {
17 EprogIO.print(s + " ==> ");
18 EprogIO.println(Berechner.getDimension(s));
19 } catch(Exception e) {
20 EprogIO.println("Exception: "+e);
21 }
22 }
23
24
25 public static void isValidOperator(String s) {
26 try {
27 EprogIO.print(s + " ==> ");
28 EprogIO.println(Berechner.isValidOperator(s));
29 } catch(Exception e) {
30 EprogIO.println("Exception: "+e);
31 }
32 }
33
34
35 public static void isValidWert(String s) {
36 try {
37 EprogIO.print(s + " ==> ");
38 EprogIO.println(Berechner.isValidWert(s));
39 } catch(Exception e) {
40 EprogIO.println("Exception: "+e);
41 }
42 }
43
44
45 public static void getWertNumeric(String s) {
46 try {
47 EprogIO.print(s + " ==> ");
48 EprogIO.println(Berechner.getWertNumeric(s));
49 } catch(Exception e) {
50 EprogIO.println("Exception: "+e);
51 }
52 }
53
54
55 public static void convertWertToFloat(String s) {
56 try {
57 EprogIO.print(s + " ==> ");
58 EprogIO.println(Berechner.convertWertToFloat(
59 Berechner.getWertNumeric(s),
60 Berechner.getEinheit(s)));
61 } catch(Exception e) {
62 EprogIO.println("Exception: "+e);
63 }
64 }
65
66 public static void berechne(String a, String op, String b) {
67 try {
68 EprogIO.print(a + op + b + " ==> ");
69 EprogIO.println(Berechner.berechne(a,op,b));
70 } catch(Exception e) {
71 EprogIO.println("Exception: "+e);
72 }
73 }
74
75
76 public static void main(String[] args) {
77
78 String[] td={
79 "40cm", "13dm2", "47qm", "16d",
80 "63.3", "12.5m3", "1m", "0.",
81 "0", "0m", "0.00m", "000.00m",
82 "0004cm", "004.00m", "0000m" };
83
84 int tds=15;
85
86 String[] ops= {
87 "40cm", "<>", "=", "+", "(",
88 ")", "*", "/", "-" };
89
90 int opss=9;
91
92
93 EprogIO.println("checke getEinheit()");
94 EprogIO.println("-------------------");
95
96 for(int i=0; i
97 getEinheit(td);
98
99 EprogIO.println();
100 EprogIO.println("checke getDimension()");
101 EprogIO.println("---------------------");
102
103 for(int i=0; i
104 getDimension(td);
105
106 EprogIO.println();
107 EprogIO.println("checke isValidOperator()");
108 EprogIO.println("------------------------");
109
110 for(int i=0; i
111 isValidOperator(ops);
112
113
114 EprogIO.println();
115 EprogIO.println("checke isValidWert()");
116 EprogIO.println("--------------------");
117
118 for(int i=0; i
119 isValidWert(td);
120
121
122 EprogIO.println();
123 EprogIO.println("checke getWertNumeric()");
124 EprogIO.println("-----------------------");
125
126 for(int i=0; i
127 getWertNumeric(td);
128
129
130 EprogIO.println();
131 EprogIO.println("checke convertWertToFloat()");
132 EprogIO.println("---------------------------");
133
134 for(int i=0; i
135 convertWertToFloat(td);
136
137
138 EprogIO.println();
139 EprogIO.println("checke berechne()");
140 EprogIO.println("-----------------");
141
142 berechne("40cm", "+", "12m");
143 berechne("urga", "+", "bla");
144 berechne("13m", "(", "15m");
145 berechne("m", "*", "5m");
146 berechne("5m2", "*", "3m");
147 berechne("5m2", "*", "5m2");
148 berechne("6m2", "/", "2cm");
149 berechne("2cm", "/", "6m2");
150 berechne("5m", "/", "0");
151 berechne("5m", "/", "0m");
152 berechne("5m", "/", "0.m");
153 berechne("5m", "/", "0.0m");
154 berechne("5m", "/", "0.000m");
155
156
157 }
158 }
|