Skip to content

Commit b006db3

Browse files
committed
read through ch06
1 parent 7fc0d15 commit b006db3

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

ch06/Exercise.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
public class Exercise {
2+
3+
public static void main(String[] args) {
4+
boolean flag1 = isHoopy(202);
5+
boolean flag2 = isFrabjuous(202);
6+
System.out.println(flag1);
7+
System.out.println(flag2);
8+
if (flag1 && flag2) {
9+
System.out.println("ping!");
10+
}
11+
if (flag1 || flag2) {
12+
System.out.println("pong!");
13+
}
14+
}
15+
16+
public static boolean isHoopy(int x) {
17+
boolean hoopyFlag;
18+
if (x % 2 == 0) {
19+
hoopyFlag = true;
20+
} else {
21+
hoopyFlag = false;
22+
}
23+
return hoopyFlag;
24+
}
25+
26+
public static boolean isFrabjuous(int x) {
27+
boolean frabjuousFlag;
28+
if (x > 0) {
29+
frabjuousFlag = true;
30+
} else {
31+
frabjuousFlag = false;
32+
}
33+
return frabjuousFlag;
34+
}
35+
36+
}

0 commit comments

Comments
 (0)