Dear Readers,
I picked up this project from the net. I finished it but I wanted to know whether there is a
better way of doing it. A
more efficient and
professional way. I know my logic is bad but I want to improve. Please don't worry about the other classes. Here are the requirements:
Write a class Scrambler.java which is once again a subclass of FileTransfer. Define a constructor for the Scrambler class using the keyword super, and write an overriding definition for the newWord method that scrambles the words in each line of text. Just remember that your program needs to scramble only the interior characters of each word, leaving the first and last characters untouched, so you'll have to separate out the leading character and the final character of each word before you scramble the interior characters. Also note that words with less than four characters can't be scrambled. Make sure that punctuation marks stay in the same place when you scramble words. For example, a period at the end of a sentence should not be processed as the last character in the word that precedes it.
Notes on using the Java API: You should make extensive use of the Java class library to implement these classes. For example, the String class and the StringBuffer class have methods that will help you a lot. The java.util.Collections class, has a shuffle method that scrambles a List (for example, an ArrayList). Therefore, a way to implement the scrambling function would be:
Put the characters to be scrambled into an ArrayList (as Character objects).
Call Collections.shuffle()
read the characters out of the ArrayList
It would be better if it is copied and pasted into your own editors. Its about 60 lines. Please don't think that this is my homework because it is NOT. I just want to improve my logic and style of writing code. Here is my code: