Word scrambler class

5
Temi O.

Transcript of Word scrambler class

Page 1: Word scrambler class

Temi O.

Page 2: Word scrambler class

*an array is created----wordArr

*Even number of objects

*string objects

* instance variable scrambledWords

Page 3: Word scrambler class

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

Apple Pear

Ap ar

Page 4: Word scrambler class

*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

Page 5: Word scrambler class

*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]);