next up previous
Next: The class EncryptedText: representation Up: Unit 06 Previous: Statements to exit from

Exercise: a class to encode texts

Specification:

Realize a Java class to represent encrypted texts. The encryption of the text is obtained by replacing each character with the character whose code is equal to the code of the character to encode augmented by an integer number representing the encryption key. The functionalities of encrypted texts are:

Solution scheme:

To realize the Java class we make use of the methodology introduced in Unit 3.

The properties and the services of interest can be immediately identified from the specification. Hence, we can start writing:

public class EncryptedText {
  // private representation of the objects of the class
  // public methods that realize the requested functionalities
  // possibly auxiliary methods
}

In the following, we will choose the representation for the objects of the class, the public interface of the class, and the realization of the methods.


next up previous
Next: The class EncryptedText: representation Up: Unit 06 Previous: Statements to exit from