Open Egis-Kevin opened 6 years ago
I was thinking that without using outside sources I could use a LinkedHashMap.
Something like:
public static LinkedHashMap<Calendar , String> getHolidaysMap() throws ParseException {
LinkedHashMap<Calendar , String> holidays = new LinkedHashMap<Calendar , String>();
String[] holidayNames = new String[] {"New Years", "New Years", "Human Wrights Day",
"Good Friday", "Family Day","Freedom Day", "WorkersDay", "Youth Day", "National womens
day", "Heritage day", "Public Holiday", "Day of reconciliation", "Chistmas", "Day Of Goodwill"};
String[] dates = new String[] {"01/01/2018", "01/02/2018","03/21/2018",
"04/14/2018","04/17/2018","04/27/2018","05/01/2018", "6/16/2018",
"08/09/2018","10/24/2018", "10/25/2018", "12/16/2018","12/25/2018", "12/26/2018"};
for(int i = 0; i < 14; i++ ) {
holidays.put(stringToCalendar(dates[i]), holidayNames[i]);
}
return holidays;
}
This would make the isHoliday method and the printHoliday method a lot simpler( and more effecient).
I can change my class to implement this?
To your second point, I left out Easter because it wan't on the list of public Holidays :) I used this site: https://www.officeholidays.com/countries/south_africa/index.php.
Have you thought of other ways in which Public Holidays could be done?
I noticed you did not include Easter as it moves around. No need for it. Did you check for algorithms for this?