I’m making a small project for my university which is supposed to enroll students into different courses. I do have one issue though, each course has start/end enrollment day. How can I now use Date/Calendar to avoid having to make my own method. I will need two though, one is setDates(), used to set start and end dates for enrollment, and second is isOpen(), which will return error if a student tries to enroll too early or too late. (Assuming the moment of applying is the moment the program is run, so basically “now”)
I’m making a small project for my university which is supposed to enroll students
Share
isOpen()can be this simple:setDates()can just be a simple setter (though you should protect the invariant that end date cannot be before start date)This type of logic is very common though and the third-party Joda-Time library does a very good job of encapsulating it for you (e.g. through the
Intervalclass and itscontainsNow()method).