Pages

Saturday, February 1, 2014

Chapter 2 - Object Oriented Programing In Java

Excercise 2 - Object Oriented Programing In Java

Reading Materials
·         Head First - Java (Read all the listed chapters)
o    7 - Better Living In Objectville
o    8 - Serious Polymorphism

Excercise:

Now you should enable the usage of several encryption algorithms.
·         Create an interface called EncryptionAlgorithm and an implementer class ShiftUpEncryption that performs the encryption algorithm used in the last exercise.
Refactor you code accordingly.
·          Create a class called FileEncryptor that receives an EncryptionAlgorithm in the constructor of the class. The class should be responsible of encryption and decryption of files. Your program should use this class to encrypt and decrypt it’s files.
An example to the method declarations (You don’t have to do it exactly this way, this is written only for clarification):
public void encryptFile(String originalFilePath, String outputFilePath,
                        String keyPath)
public void decryptFile(String encryptedFilePath, String outputFilePath,
                        String keyPath)

·         Create another algorithm called ShiftMultiplyEncryption, it should do the same thing as ShiftUpEncryption, but instead of adding the value of the key to each character, it should multiply it’s value with the value of the character.
o    Think how you can write this class without code duplication of ShiftUpEncryption.
·         Create an algorithm called DoubleEncryption that uses an existing EncryptionAlgorithm (not necessarily ShiftUpEncryption) and uses it twice to perform stronger encryption (It should use a different key each time you apply the encryption).
o    Bonus: Create a class called RepeatEncryption that receives in the constructor a number “n” and an encryption algorithm, and performs the operations “n” times (with the same key).
o    Bonus: Create a class called XorEncryption the performs the XOR (exclusive or) between the key and the character.
·         Finally the program should use double shift up encryption (DoubleEncryption + ShiftUp).

o    Emphasis: There is no need to make a menu of choosing different methods of encryption. You should check all the different encryption classes in another way.

No comments:

Post a Comment