Campbell Ritchie wrote:
I am afraid I am an awkward so‑and‑so who makes life difficult for all whom I encounter.Anders hofel wrote: . . . The method createAgreement, must throw a RuntimeException . . .
I think you should query that instruction with your teacher; in my opinion, that method should throw a non‑runtime exception. Then the compiler will force the calling method to handle the Exception. You should also get rid of the return null; bit, which is unnecessary and also nulls are potentially dangerous. I think your method should look like thisI cannot understand the logic of your Agreement class. You appear to be passing one date to its constructor, so how do you work out start date and end date? And where does 1st January 2011 come from? Are you adding to a static Agreement class method or to a List called Agreements? If you have a List called Agreements, do you need to return the Agreement object, or can you give the method void return type?
Carey Brown wrote:Your requirements say to throw a RuntimeException, instead you are catching one.
Campbell Ritchie wrote:Welcome to the Ranch (again).
Why are you looking for sources in the actionPerformed method? Create one class per action required, add it to a particular control (e.g. a button) and there is no need for non‑object‑oriented tests for the source.
Matthew Brown wrote:Hi Anders. Welcome to the Ranch!
ArrayStoreException happens when you try to put an object into an array that is the wrong type. Fortunately, the stack trace tells you exactly where this is happening. It's pointing to this line:
personer is an ArrayList<Person>. So in that line you're trying to convert a list of Person to an array of String. Try converting it to an array of the same type.