Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String scramble(String toScramble)
- {
- String meh = "";
- ArrayList alph = new ArrayList();
- for(int i = 0;i<alpha.length();i++)
- {alph.add(alpha.charAt(i));}
- scrambled = new ArrayList();
- while(alph.size()>0)
- {
- int spot = (int)(Math.random()*alph.size());
- scrambled.add(alph.get(spot));
- alph.remove(spot);
- }
- toScramble = toScramble.toUpperCase();
- for(int i = 0;i<toScramble.length();i++)
- {
- char p = toScramble.charAt(i);
- int ind = indexOff(alph,p);
- meh+=scrambled.get(ind);
- }
- return meh.toLowerCase();
- }
- public int indexOff(ArrayList a,char b)
- {
- int index = 0;
- while(index<a.size())
- {
- if(a.get(index) == b) return index;
- }
- return -1;
- }
Add Comment
Please, Sign In to add comment