Hi,
I am having some trouble with understanding the syntax of the new topic i school, exception handling.
The task is :
The method createAgreement, must throw a RuntimeException with an appropriate text, if you try to create an agreement that overlaps the timespan of an existing agreeement. Which means if the new agreeement has a "fromDate" in between the "fromDate" and "endDate" of an existing agreeement. Or if the new "fromDate" is after "fromDate" on an agreement that does not yet have a "endDate" (is null).
The constructor of an Agreement takes only the parameter of the "fromDate", as the "endDate" is not known untill the Agreement is cancelled.
Se my code below, which is obviously not working. My main problem is, that i cannot see how an exception could occur? in my head i want to "Catch" the event of the if's not being true, and an exeption to occur then - but that doesnt seem quite right either
also, the placement of the try/catch, and return statements is abit confusing.
Please help!