daboyz/Eckel — pull request #1 by VasylKo (2014-10-15 11:06:54+00:00)
Title: Update Exercise11.java

package com.Unit10_Interface;

public class Producer {

public String toString(char[] ch) {
String s = "";
for (int i = 0; i < ch.length; i++) {
s += ch[i];
}

return s;
}

public String produce (String take) {
char[] ch = new char[take.length()];

for (int i = 0; i < (take.length() - 1); i = i + 2 ) {
ch[i] = take.charAt(i+1);
ch[i+1] = take.charAt(i);
}
if (take.length()%2 != 0) {
ch[take.length() - 1] = take.charAt(take.length() - 1);
}
return toString(ch);
}

}