We won't shuffle the array yet - that is coming soon. In this section we will
complete the rest of the methods of our
ShuffledWordLibrary
. Our getWord()
now
gets the new index from the array and then returns other.getWord(newIdx)
. We
do something similar for getScrambledWord()
.
What we are doing in our ScambledWordDictionary
is delegating the work of
providing words to the other WordLibrary
. This is a good way of structuring
our system - get other classes to do the work. We call this the Single
Responsibility Principle (SRP) - every class has exactly one purpose. The
StaticWordLibrary
gives back scrambled words. The ShuffledWordLibrary
shuffles
the words, etc.
We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.
We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.
We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...