September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
41
Task/Extend-your-language/Java/extend-your-language-3.java
Normal file
41
Task/Extend-your-language/Java/extend-your-language-3.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
public class If2 {
|
||||
private final boolean firstCondition;
|
||||
private final boolean secondCondition;
|
||||
|
||||
public If2(boolean firstCondition, boolean secondCondition) {
|
||||
this.firstCondition = firstCondition;
|
||||
this.secondCondition = secondCondition;
|
||||
}
|
||||
|
||||
public static If2 if2(boolean firstCondition, boolean secondCondition) {
|
||||
return new If2(firstCondition, secondCondition);
|
||||
}
|
||||
|
||||
public If2 then(Runnable runnable) {
|
||||
if (firstCondition && secondCondition) {
|
||||
runnable.run();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public If2 elseNone(Runnable runnable) {
|
||||
if (!firstCondition && !secondCondition) {
|
||||
runnable.run();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public If2 elseIfFirst(Runnable runnable) {
|
||||
if (firstCondition && !secondCondition) {
|
||||
runnable.run();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public If2 elseIfSecond(Runnable runnable) {
|
||||
if (!firstCondition && secondCondition) {
|
||||
runnable.run();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue