83 lines
2.7 KiB
Java
83 lines
2.7 KiB
Java
package xyz.etztech.minecraftmanager.objects;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
public enum Question {
|
|
|
|
ONE("How old are you?", "Your answer must be numeric."),
|
|
TWO("How do you typically enjoy playing Minecraft?", "Your answer must be under 300 characters long."),
|
|
THREE1("Have you ever been banned? Please answer just 'yes' or 'no'.", "Your answer must be just 'yes' or 'no'."),
|
|
THREE2("Oof. That's okay, it's happened to plenty of people. Do you mind letting us know why?", "Your answer must be under 300 characters long."),
|
|
FOUR("How did you find out about our server?", "Your answer must be under 50 characters long."),
|
|
FIVE("Last question! Have you read the rules thoroughly?", "Your answer must be under 10 characters long."),
|
|
COMPLETE("All done! Staff should be reviewing your application any second now!", "");
|
|
|
|
public static final String READ_RULES = "Are you sure? Maybe you should read them again...";
|
|
|
|
private String question;
|
|
private String error;
|
|
|
|
Question(String s, String e) {
|
|
question = s;
|
|
error = e;
|
|
}
|
|
|
|
|
|
public String getQuestion() {
|
|
return question;
|
|
}
|
|
|
|
public String getError() {
|
|
return error;
|
|
}
|
|
|
|
public static Question last(Question question) {
|
|
if (question == TWO) {
|
|
return ONE;
|
|
} else if (question == THREE1) {
|
|
return TWO;
|
|
} else if (question == THREE2) {
|
|
return THREE1;
|
|
} else if (question == FOUR) {
|
|
return THREE2;
|
|
} else {
|
|
return FOUR;
|
|
}
|
|
}
|
|
|
|
public static Question next(Question question, String answer) {
|
|
if (question == ONE) {
|
|
return TWO;
|
|
} else if (question == TWO) {
|
|
return THREE1;
|
|
} else if (question == THREE1) {
|
|
return answer.equalsIgnoreCase("yes") ? THREE2 : FOUR;
|
|
} else if (question == THREE2) {
|
|
return FOUR;
|
|
} else if (question == FOUR) {
|
|
return FIVE;
|
|
} else {
|
|
return COMPLETE;
|
|
}
|
|
}
|
|
|
|
public static boolean validate(Question question, String answer) {
|
|
if (question == ONE) {
|
|
return StringUtils.isNumeric(answer);
|
|
} else if (question == TWO) {
|
|
return answer.length() <= 300;
|
|
} else if (question == THREE1) {
|
|
return answer.equalsIgnoreCase("yes") || answer.equalsIgnoreCase("no");
|
|
} else if (question == THREE2) {
|
|
return answer.length() <= 300;
|
|
} else if (question == FOUR) {
|
|
return answer.length() <= 50;
|
|
} else if (question == FIVE) {
|
|
return answer.length() <= 10;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|