| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
package com.stevesoft.pat; |
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| |
|
| 0% |
Uncovered Elements: 80 (80) |
Complexity: 30 |
Complexity Density: 0.73 |
|
| 14 |
|
public class patInt |
| 15 |
|
{ |
| 16 |
|
int i; |
| 17 |
|
|
| 18 |
|
boolean inf; |
| 19 |
|
|
| 20 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 21 |
0 |
public patInt()... |
| 22 |
|
{ |
| 23 |
0 |
i = 0; |
| 24 |
0 |
inf = false; |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 28 |
0 |
public patInt(int init)... |
| 29 |
|
{ |
| 30 |
0 |
i = init; |
| 31 |
0 |
inf = false; |
| 32 |
|
} |
| 33 |
|
|
| 34 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 35 |
0 |
public patInt(patInt p)... |
| 36 |
|
{ |
| 37 |
0 |
i = p.i; |
| 38 |
0 |
inf = p.inf; |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 42 |
0 |
public void setInf(boolean b)... |
| 43 |
|
{ |
| 44 |
0 |
inf = b; |
| 45 |
0 |
if (b) |
| 46 |
|
{ |
| 47 |
0 |
i = Integer.MAX_VALUE; |
| 48 |
|
} |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 52 |
0 |
public final void inc()... |
| 53 |
|
{ |
| 54 |
0 |
if (!inf) |
| 55 |
|
{ |
| 56 |
0 |
i++; |
| 57 |
|
} |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 61 |
0 |
public final void dec()... |
| 62 |
|
{ |
| 63 |
0 |
if (!inf) |
| 64 |
|
{ |
| 65 |
0 |
i--; |
| 66 |
|
} |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 70 |
0 |
public final boolean lessEq(patInt j)... |
| 71 |
|
{ |
| 72 |
|
|
| 73 |
|
|
| 74 |
0 |
return !inf && (j.inf || i <= j.i); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
0 |
public final boolean equals(patInt j)... |
| 79 |
|
{ |
| 80 |
0 |
return !j.inf && !inf && i == j.i; |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 87 |
0 |
final public String toString()... |
| 88 |
|
{ |
| 89 |
0 |
if (inf) |
| 90 |
|
{ |
| 91 |
0 |
return ""; |
| 92 |
|
} |
| 93 |
|
else |
| 94 |
|
{ |
| 95 |
0 |
return "" + i; |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 102 |
0 |
public final patInt pluseq(patInt p)... |
| 103 |
|
{ |
| 104 |
0 |
if (inf || p.inf) |
| 105 |
|
{ |
| 106 |
0 |
setInf(true); |
| 107 |
|
} |
| 108 |
|
else |
| 109 |
|
{ |
| 110 |
0 |
i += p.i; |
| 111 |
|
} |
| 112 |
0 |
return this; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 119 |
0 |
public final patInt mul(patInt p)... |
| 120 |
|
{ |
| 121 |
0 |
if (inf || p.inf) |
| 122 |
|
{ |
| 123 |
0 |
return new patInf(); |
| 124 |
|
} |
| 125 |
0 |
return new patInt(i * p.i); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 132 |
0 |
public final patInt mineq(patInt p)... |
| 133 |
|
{ |
| 134 |
0 |
if (p.inf) |
| 135 |
|
{ |
| 136 |
0 |
return this; |
| 137 |
|
} |
| 138 |
0 |
if (inf) |
| 139 |
|
{ |
| 140 |
0 |
i = p.i; |
| 141 |
|
} |
| 142 |
0 |
else if (p.i < i) |
| 143 |
|
{ |
| 144 |
0 |
i = p.i; |
| 145 |
|
} |
| 146 |
0 |
setInf(false); |
| 147 |
0 |
return this; |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 153 |
0 |
public final patInt maxeq(patInt p)... |
| 154 |
|
{ |
| 155 |
0 |
if (inf || p.inf) |
| 156 |
|
{ |
| 157 |
0 |
setInf(true); |
| 158 |
0 |
return this; |
| 159 |
|
} |
| 160 |
0 |
if (p.i > i) |
| 161 |
|
{ |
| 162 |
0 |
i = p.i; |
| 163 |
|
} |
| 164 |
0 |
return this; |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 168 |
0 |
public boolean finite()... |
| 169 |
|
{ |
| 170 |
0 |
return !inf; |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 176 |
0 |
public int intValue()... |
| 177 |
|
{ |
| 178 |
0 |
return inf ? Integer.MAX_VALUE : i; |
| 179 |
|
} |
| 180 |
|
}; |