Question: Here is my programming II homework: Create a program that involves the Encryptable interface. Encryptable interface has two methods: encrypt() that encrypts data and returns
Here is my programming II homework:
Create a program that involves theEncryptableinterface.
Encryptable interface has two methods:
encrypt() that encrypts data and returns the encrypted data
decrypt() that decrypts data and returns the decrypted data
Implement an abstract class calledEncryptionthat claims it is implementing Encryptable.
This class should have a boolean attribute that represents whether the object is encrypted or not. Make sure all required methods are implemented.
Implement a concrete class calledPasswordthat inherits from Encryptionand has a String attribute and an integer constant set to 32.
It implements the Encryptable method encrypt(), by creating and returning another String. In the new String, each character of original String is replaced with the character 32 positions before it, based on ASCII code. For example: A that is 65 will change to ! which is 33. The reverse is done for decrypt().
Then implement another concrete class calledSecretthat also inherits from Encryption.It should have an int attribute.
Come up with an algorithm to encrypt (and decrypt) the attribute.
The tester should create anarrayof Encryptable objects and assign a few Password and Secret objects to it.
Add two loops:
1- To print the values of each object and call encrypt method on each object, if the object is not encrypted.
2- To print the values of each object and call decrypt method,if the object is encrypted.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
