Boxing 15 - ported to java

This commit is contained in:
Ignacio Manzano
2021-03-22 09:12:26 -03:00
parent 64f007a049
commit ed0663ccbe
7 changed files with 483 additions and 0 deletions

27
15 Boxing/java/Punch.java Normal file
View File

@@ -0,0 +1,27 @@
import java.util.Arrays;
/**
* Types of Punches
*/
public enum Punch {
FULL_SWING(1),
HOOK(2),
UPPERCUT(3),
JAB(4);
private final int code;
Punch(int code) {
this.code = code;
}
int getCode() { return code;}
public static Punch fromCode(int code) {
return Arrays.stream(Punch.values()).filter(p->p.code == code).findAny().orElse(null);
}
public static Punch random() {
return Punch.fromCode(Basic.randomOf(4));
}
}