This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +72
-1
lines changed
main/java/com/kylecorry/geometry
test/java/com/kylecorry/geometry Expand file tree Collapse file tree 4 files changed +72
-1
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <module external.linked.project.id=" Geometry" external.linked.project.path=" $MODULE_DIR$" external.root.project.path=" $MODULE_DIR$" external.system.id=" GRADLE" external.system.module.group=" com.kylecorry.geometry" external.system.module.version=" 0.7" type =" JAVA_MODULE" version =" 4" >
3+ <component name =" NewModuleRootManager" inherit-compiler-output =" true" >
4+ <exclude-output />
5+ <content url =" file://$MODULE_DIR$" >
6+ <excludeFolder url =" file://$MODULE_DIR$/.gradle" />
7+ <excludeFolder url =" file://$MODULE_DIR$/build" />
8+ <excludeFolder url =" file://$MODULE_DIR$/out" />
9+ </content >
10+ <orderEntry type =" inheritedJdk" />
11+ <orderEntry type =" sourceFolder" forTests =" false" />
12+ </component >
13+ </module >
Original file line number Diff line number Diff line change 11group ' com.kylecorry.geometry'
2- version ' 0.6.1 '
2+ version ' 0.7 '
33
44apply plugin : ' java-library'
55
Original file line number Diff line number Diff line change 1+ package com .kylecorry .geometry ;
2+
3+ public class Range {
4+
5+ private double low ;
6+ private double high ;
7+
8+ public Range (double low , double high ) {
9+ this .low = low ;
10+ this .high = high ;
11+ }
12+
13+ public double getLow () {
14+ return low ;
15+ }
16+
17+ public double getHigh () {
18+ return high ;
19+ }
20+
21+ public boolean inRangeInclusive (double value ){
22+ return getLow () <= value && getHigh () >= value ;
23+ }
24+
25+ public boolean inRangeExclusive (double value ){
26+ return getLow () < value && getHigh () > value ;
27+ }
28+
29+ }
Original file line number Diff line number Diff line change 1+ package com .kylecorry .geometry ;
2+
3+ import org .junit .Test ;
4+
5+ import static org .junit .Assert .*;
6+
7+ public class RangeTest {
8+
9+ @ Test
10+ public void testRangeInclusive (){
11+ Range r = new Range (0 , 100 );
12+ assertTrue (r .inRangeInclusive (0 ));
13+ assertTrue (r .inRangeInclusive (100 ));
14+ assertTrue (r .inRangeInclusive (50 ));
15+ assertFalse (r .inRangeInclusive (-1 ));
16+ assertFalse (r .inRangeInclusive (101 ));
17+ }
18+
19+ @ Test
20+ public void testRangeExclusive (){
21+ Range r = new Range (0 , 100 );
22+ assertFalse (r .inRangeExclusive (0 ));
23+ assertFalse (r .inRangeExclusive (100 ));
24+ assertTrue (r .inRangeExclusive (50 ));
25+ assertFalse (r .inRangeExclusive (-1 ));
26+ assertFalse (r .inRangeExclusive (101 ));
27+ }
28+
29+ }
You can’t perform that action at this time.
0 commit comments