Interface JumbleStrategy

All Known Implementing Classes:
SimpleJumbleStrategy

public interface JumbleStrategy
Provides a strategy for generating a jumbled string from the provided text and specified size. This interface decouples the jumble strategy from the core implementation, allowing different strategies to be implemented and swapped dynamically. The strategy involves inserting random symbols between the words to meet a specified total length.

Implementations of this interface will need to define the jumble method to create a jumbled string that meets the following criteria:

  • Each word from the input is included once.
  • Random symbols are added between the words to reach the specified size.
  • If the specified size is smaller than the total number of characters of the words combined, an IllegalArgumentException is thrown.
Author:
Kheagen Haskins
  • Method Summary

    Modifier and Type
    Method
    Description
    jumble(String[] words, int size)
    Generates a jumbled version of the provided string by inserting random symbols to meet the specified size.
  • Method Details

    • jumble

      String jumble(String[] words, int size)
      Generates a jumbled version of the provided string by inserting random symbols to meet the specified size.
      Parameters:
      words - the input strings to be jumbled.
      size - the desired total size of the resulting jumbled string, which must be at least as long as the total number of characters in str.
      Returns:
      the jumbled string of the specified size.
      Throws:
      IllegalArgumentException - if the specified size is smaller than the total number of characters in str.