forked from hellokaton/write-readable-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample4.java
More file actions
32 lines (26 loc) · 826 Bytes
/
Copy pathExample4.java
File metadata and controls
32 lines (26 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package chapter_09;
/**
* 与复杂的逻辑斗争
*
* @author biezhi
* @date 2018/7/14
*/
public class Example4 {
class Range{
int begin;
int end;
// 如:(0, 5) 会和 (3, 8) 重合
// (0, 2) (2,4)
boolean overlapsWith(Range other){
// 检查自己的任意端点是否在 other 的范围之内
// return (begin >= other.begin && begin <= other.end) ||
// (end >= other.begin && end <= other.end);
// return (begin >= other.begin && begin < other.end) ||
// (end > other.begin && end <= other.end) ||
// (begin <= other.begin && end >= other.end);
if(other.end <= begin) return false;
if(other.begin >= end) return false;
return true;
}
}
}