Guest User

Untitled

a guest
Jul 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public String scramble(String toScramble)
  2. {
  3. String meh = "";
  4. ArrayList alph = new ArrayList();
  5. for(int i = 0;i<alpha.length();i++)
  6. {alph.add(alpha.charAt(i));}
  7.  
  8. scrambled = new ArrayList();
  9. while(alph.size()>0)
  10. {
  11. int spot = (int)(Math.random()*alph.size());
  12. scrambled.add(alph.get(spot));
  13. alph.remove(spot);
  14. }
  15.  
  16. toScramble = toScramble.toUpperCase();
  17. for(int i = 0;i<toScramble.length();i++)
  18. {
  19. char p = toScramble.charAt(i);
  20. int ind = indexOff(alph,p);
  21. meh+=scrambled.get(ind);
  22. }
  23. return meh.toLowerCase();
  24. }
  25.  
  26. public int indexOff(ArrayList a,char b)
  27. {
  28. int index = 0;
  29. while(index<a.size())
  30. {
  31. if(a.get(index) == b) return index;
  32. }
  33. return -1;
  34. }
Add Comment
Please, Sign In to add comment