Pages

Saturday, February 1, 2014

Chapter 4 - Exceptions In Java

Reading Materials
·         Head First - Java (Read all the listed chapters)
o    10 - Numbers Matter
o    11 - Risky Behavior

Excercise:

1.     Add exception handling to your encryption program.
·         Your encryption algorithms should throw InvalidEncryptionKeyException in case the key is not in the correct format.
                                          i.    Show the user an appropriate error message in that case.
·         Your program should throw another kind of exception in case the paths that were passed are not valid.
2.     Add a method to EncryptionAlgorithm that is called getKeyStrength that describes that maximal length (number of digits) of the key for the algorithm.
For example if the key is between 0-256 then the value of the algorithm should be 3.
·         Implement the property for each and one of you algorithms.
·         Create a class that implements “Comparator<T>” and compares between two algorithms by their key strengths.
·         Add suitable unit test accordingly

                                          i.    Do you know how to check if an exception is thrown via JUnit? 

No comments:

Post a Comment