Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<String> logs = new ArrayList<String>();
- public static class ErrorHandler {
- public static class timeErrors {
- public static void error0fx4() {
- System.out.println("Invalid time format. Please try again.");
- logs.add("Error 0fx4: Time hour bigger than 24 or smaller than 0");
- }
- public static void error0fx5() {
- System.out.println("Invalid time format. Please try again.");
- logs.add("Error 0fx5: Time minute bigger than 59 or smaller than 0");
- }
- }
- }
- public static final class timeCheck {
- public static void printRules() {
- System.out.println("1. Do not put more than 59 minutes\n2. Do not put less than 0 minutes.\n3. DO NOT, IN ANY CASE, MAKE THE HOUR SINGLE DIGIT. PUT A ZERO BEHIND IT.\n4. Do not put more than 24 hours.\n5. Do not put less than 0 hours.");
- }
- public static void checkAfternoon(double time) {
- String timeStr = String.valueOf(time);
- if (time > 24 || time < 0) { // error check
- ErrorHandler.timeErrors.error0fx4();
- } else if (time < 10) { // exception of errors: needed for next error check
- timeStr = "0" + timeStr;
- time = Double.parseDouble(timeStr);
- } else if (Integer.parseInt(String.valueOf(timeStr.charAt(3))) >= 6 || Integer.parseInt(String.valueOf(timeStr.charAt(3))) < 0) {
- ErrorHandler.timeErrors.error0fx5();
- } else { // code running
- boolean passed;
- if (time < 12) {
- passed = false;
- } else {
- passed = true;
- }
- // System.out.println(time);
- System.out.println(passed);
- }
- }
- }
Add Comment
Please, Sign In to add comment