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:
Originally posted by Shyam Murarka: I picked up this project from the net.
I've written my own version, but before I paste the code, can you post the URL of the original website from where you got the question so I can read it in full, as it sounds like a disguised assignment.
Dear Kashif, I picked up this project from RentACoder. I usually go there to see if I can get hold of easy work so that I can practice. And please don't post your full code, if possible, please tell me where I have gone wrong and how I should improve it.