1 |
|
package fi.jyu.mit.ohj2; |
2 |
|
|
3 |
|
import java.io.*; |
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
@author |
14 |
|
@version |
15 |
|
|
|
|
| 23,1% |
Uncovered Elements: 30 (39) |
Complexity: 14 |
Complexity Density: 0,58 |
|
16 |
|
class Readkey |
17 |
|
{ |
18 |
|
private static native char getCharNative(); |
19 |
|
private static boolean islib = false; |
20 |
|
private static BufferedReader linereader; |
21 |
|
|
|
|
| 66,7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 0,5 |
|
22 |
1
|
static {... |
23 |
1
|
try { |
24 |
1
|
System.loadLibrary("readkey"); |
25 |
0
|
islib = true; |
26 |
|
} |
27 |
|
|
28 |
|
|
29 |
1
|
catch (UnsatisfiedLinkError e) { e.getMessage(); } |
30 |
0
|
catch (SecurityException e) { e.getMessage(); } |
31 |
|
|
32 |
1
|
init(); |
33 |
|
|
34 |
|
} |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
40 |
11
|
public static void init() {... |
41 |
11
|
if (!islib) linereader = new BufferedReader(new InputStreamReader(System.in)); |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@return |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0,62 |
|
49 |
0
|
public static char getChar() {... |
50 |
0
|
if (islib) return getCharNative(); |
51 |
|
|
52 |
0
|
String s = ""; |
53 |
0
|
try { |
54 |
0
|
s = linereader.readLine(); |
55 |
|
} catch (IOException ex) { |
56 |
|
} |
57 |
0
|
if ( ( s == null ) || ( s.equals("") ) ) return '\n'; |
58 |
0
|
return s.charAt(0); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
@return |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0
|
public static boolean isLibLoaded() {... |
67 |
0
|
return islib; |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
@param |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0,43 |
|
74 |
0
|
public static void main(String[] args)... |
75 |
|
{ |
76 |
0
|
if (isLibLoaded()) |
77 |
0
|
System.out.print("readkey-kirjasto ladattu.\nAnna merkki:"); |
78 |
|
else |
79 |
0
|
System.out.print("readkey-kirjastoa ei löytynyt.\nAnna kirjain ja paina enter:"); |
80 |
0
|
char c = Readkey.getChar(); |
81 |
0
|
if (isLibLoaded()) System.out.println(c); |
82 |
0
|
System.out.println("Annoit merkin: " + c); |
83 |
|
} |
84 |
|
|
85 |
|
} |