Word scrambler class

Post on 23-Jul-2015

463 views 0 download

Transcript of Word scrambler class

Temi O.

*an array is created----wordArr

*Even number of objects

*string objects

* instance variable scrambledWords

*makes a string with the 1st half of word1 and the 2nd half of word2

Apple Pear

Ap ar

*To get the first half of word1------divide the word length by 2

*Use 0 to the new value as the first half of your new recombined word

*To get the second half of word2---divide the word length by 2

*Use the new value to the end as the second half of the new recombined

*Word1.substring(o,wordlength()/2)+word2.substring(word2.length()/2));

Apple Pear

Ap ar

*creates an array list from recombine

*each pair of words creates 2 recombined words

* length of the new array=length of old array

* loop through the array length

*Call recombine(words[i], words[i+1]);

recombine(words[i+1], words[i]);