Instructions wrote:SmallException and BigException are individual exception classes deriving from Exception class.
Keit Koppel wrote:
Instructions wrote:exception classes deriving from Exception class.
If that is anything like the lab exercises I used to have to do, it might mean that OP was supposed to create OwnException last week and now has to enhance it with those two methods. Otherwise OwnException might have been provided ready‑made.Carey Brown wrote:. . . mention of a "ownException" class. . . .
Liutauras Vilda wrote:And need to say, that your code doesn't even compile.
The suggestion regarding that is: try to compile code after every written 2 lines of code, if possible - after every single line. Some parts of the code require having 2 lines of code to compile, so I'd say optimum is 2 at the beginning.
That way you'd know you made a mistake at earlier rather than later. That way also easier to fix mistakes, because you have to deal with less of them. That is important.
Please try to implement only SmallException class and post it here so we could verify whether you can follow requirements in general.
Carey Brown wrote:One thing not clear here is mention of a "ownException" class. This does not begin with an upper case letter as all classes should. It doesn't mention that this is a class you should create. Were you provided this class?
Carey Brown wrote:
Carey Brown wrote:One thing not clear here is mention of a "ownException" class. This does not begin with an upper case letter as all classes should. It doesn't mention that this is a class you should create. Were you provided this class?
These all need to be a part of the OwnException class or some other class that you create. The requirements are a bit vague on this so I'm assuming it is the OwnException class. Can you modify it?Carey Brown wrote:
printErrorReport method receives the exception as a parameter and prints the error report of the exception using getMessage method. testValue method receives the tested number as a parameter. If the number is lower than five, method throws the SmallException and parameter is the message: Value is lower than 5. If the number is higher than 10, method throws the BigException and parameter is the message: Value is higher than 10.
Carey Brown wrote:
These all need to be a part of the OwnException class or some other class that you create. The requirements are a bit vague on this so I'm assuming it is the OwnException class. Can you modify it?Carey Brown wrote:
printErrorReport method receives the exception as a parameter and prints the error report of the exception using getMessage method. testValue method receives the tested number as a parameter. If the number is lower than five, method throws the SmallException and parameter is the message: Value is lower than 5. If the number is higher than 10, method throws the BigException and parameter is the message: Value is higher than 10.
Keit Koppel wrote:I can´t changet the ownException class which is already made by the person who create this excersises. I assume that I must create another ownException class then.
Instructions wrote:Your task is to complete the program by writing two classes (SmallException and BigException) and two methods to the ownException class (printErrorReport and testValue).
Keit Koppel wrote:I can´t changet the ownException class which is already made by the person who create this excersises.
Campbell Ritchie wrote:How much of that code did you write yourself and how much were you given?
Why are BigException and SmallException apparently inner classes? And OwnException appears to be an inner class in ownException Didn't you tell Eclipse to create those classes separately?
Don't catch input mismatch exceptions. Use the method shown here, which can be relied upon never to throw an input mismatch exception.
You are not doing anything in the testValue method called from line 22, and that method doesn't declare that it might throw any Exceptions, so the catch block can never be executed. That is why you are getting those errors.
Keit Koppel wrote:My part is line 33 till to the end .
Don't get me started about those stupid light bulbs. |