Java Bootcamp – Workbooks and Challenges
)}

Quidditch – Part 6

Goal: Quality control the Game class.

Unchecked exceptions

An unchecked exception crashes the app as a result of badly written code.

You should throw an:

  • IllegalArgumentException when the caller passes faulty arguments into a method/constructor.

  • IllegalStateException when an object calls its method at a "bad time" (object not in a legal state).

Throwing an unchecked exception forces the caller to improve their code.

Task 1 – Inspecting the Game class


  • setScore is vulnerable to receiving null objects and adding them as keys. Throw an IllegalArgumentException to prevent that.

  • All other methods/constructors will respond appropriately when presented with illegal arguments.

Feedback Summary
4.8
38 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.