forked from hellokaton/write-readable-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample3.java
More file actions
34 lines (29 loc) · 849 Bytes
/
Copy pathExample3.java
File metadata and controls
34 lines (29 loc) · 849 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
33
34
package chapter_09;
/**
* 使用德摩根定理
* 滥用短路逻辑
*
* @author biezhi
* @date 2018/7/14
*/
public class Example3 {
/**
* 1) not (a or b or c) <=> (not a) and (not b) and (not c)
* 2) not (a and b and c) <=> (not a) or (not b) or (not c)
*/
public void part1(boolean fileExists, boolean isProtected) {
// if (!(fileExists && !isProtected)) {
// throw new RuntimeException("对不起,无法读取该文件");
// }
if (!fileExists || isProtected) {
throw new RuntimeException("对不起,无法读取该文件");
}
}
public void part2() {
// assert((!(bucket = findBucket(key)) && bucket->isOccupied()))
// bucket = findBucket(key)
// if bucket != null {
// assert bucket.isOccupied
// }
}
}