range literals initial

This commit is contained in:
Dmitry Jemerov
2011-04-28 19:24:07 +02:00
parent 5e2d8869cf
commit b95498624f
7 changed files with 72 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package jet;
public class IntRange implements Range<Integer> {
private final int startValue;
private final int endValue;
public IntRange(int startValue, int endValue) {
this.startValue = startValue;
this.endValue = endValue;
}
@Override
public boolean contains(Integer item) {
if (item == null) return false;
if (startValue <= endValue) {
return item >= startValue && item <= endValue;
}
return item <= startValue && item >= endValue;
}
}
+5
View File
@@ -0,0 +1,5 @@
package jet;
public interface Range<T extends Comparable<T>> {
boolean contains(T item);
}
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>