Created attachment 147 [details] Bug_1 Steps To Reproduce: 1. startNewDay without any date Actual Results: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1 at code.CmdStartNewDay.execute(CmdStartNewDay.java:13) at Main.main(Main.java:45) Expected Results: A warning of no date or wrong syntax
Created an extra ExInvalidDate.java to handle the exception of invalid date input. package code; public class ExInvalidDate extends Exception { private String day; public String getDay() { return day; } public ExInvalidDate() { super("Invalid date."); } public ExInvalidDate(String message) { super(message); } } -------------- In the CmdStartNewDay.java. Changed the public void execute(String[] cmdParts) as follow: public void execute(String[] cmdParts) { try { SystemDate sd = SystemDate.getInstance(); sOld = sd.toString(); sNew = cmdParts[1]; if (!sd.valid(sNew)) throw new ExInvalidDate(); sd.set(sNew); addUndoCommand(this); clearRedoList(); System.out.println("Done."); } catch (ExInvalidNewDate e) { System.out.println(e.getMessage()); } catch (ExInvalidDate | ArrayIndexOutOfBoundsException | NumberFormatException e) { System.out.println(new ExInvalidDate().getMessage()); } }