Created
May 16, 2018 10:10
-
-
Save Venipa/9ace179cd79b968540a9e58053a53698 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package banknoten; | |
import java.util.Random; | |
import java.util.Scanner; | |
public class Helper { | |
public static String ReadLine() { | |
return ReadLine(new Scanner(System.in), 0); | |
} | |
public static String ReadLine(Scanner sc, int musthaveLength) { | |
if (sc.hasNext()) sc.nextLine(); | |
String res = ""; | |
if(musthaveLength != 0) { | |
while(res.trim().length() != musthaveLength) { | |
res = sc.nextLine(); | |
System.out.println(res.trim().length()); | |
} | |
} else { | |
res = sc.nextLine(); | |
} | |
return res; | |
} | |
public static String RandString(int length) { | |
String characters = "abcdefghijklmnopqrstuvwxyz"; | |
characters += characters.toUpperCase(); | |
char[] _chars = characters.toCharArray(); | |
StringBuilder sb = new StringBuilder(); | |
for (int i : new int[length]) { | |
sb.append(Character.toString(_chars[new Random(((length-1 < 0 || length-1 > _chars.length) ? 0 : length)).nextInt()])); | |
} | |
return sb.toString(); | |
} | |
public static int getLatinIndex(char input) { | |
char[] _latinchars = "abcdefghijklmnopqrstuvwxyz".toUpperCase().toCharArray(); | |
char _char = Character.toString(input).toUpperCase().charAt(0); | |
int counter = 0; | |
for(char c : _latinchars) { | |
if(_char == c) return counter; | |
counter++; | |
} | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment