mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
27
15_Boxing/java/Punch.java
Normal file
27
15_Boxing/java/Punch.java
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user