Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Banner {
- private static String[][] zahlen = {
- {
- " *** ",
- " * * ",
- "* * ",
- "* * ",
- "* * ",
- " * * ",
- " *** ",
- " "
- },
- {
- " * ",
- " ** ",
- "* * ",
- " * ",
- " * ",
- " * ",
- "***** ",
- " "
- },
- {
- " ***** ",
- "* * ",
- " * ",
- " ***** ",
- "* ",
- "* ",
- "******* ",
- " "
- },
- {
- " ***** ",
- "* * ",
- " * ",
- " ***** ",
- " * ",
- "* * ",
- " ***** ",
- " "
- },
- {
- "* ",
- "* * ",
- "* * ",
- "******* ",
- " * ",
- " * ",
- " * ",
- " "
- },
- {
- "******* ",
- "* ",
- "* ",
- "****** ",
- " * ",
- "* * ",
- " ***** ",
- " "
- },
- {
- " ***** ",
- "* ",
- "* ",
- "****** ",
- "* * ",
- "* * ",
- " ***** ",
- " "
- },
- {
- "******* ",
- "* * ",
- " * ",
- " * ",
- " * ",
- " * ",
- " * ",
- " "
- },
- {
- " ***** ",
- "* * ",
- "* * ",
- " ***** ",
- "* * ",
- "* * ",
- " ***** ",
- " "
- },
- {
- " ***** ",
- "* * ",
- "* * ",
- " ****** ",
- " * ",
- "* * ",
- " ***** ",
- " "
- }
- };
- public static int getIntAt(String input, int pos) {
- switch (input.charAt(pos)) {
- case '0': return 0;
- case '1': return 1;
- case '2': return 2;
- case '3': return 3;
- case '4': return 4;
- case '5': return 5;
- case '6': return 6;
- case '7': return 7;
- case '8': return 8;
- case '9': return 9;
- default: return -1;
- }
- }
- public static void main(String[] args) {
- //String input = args[0];
- String input = "01234567891A";
- // Maximal 10 Zeichen ausgeben
- int length = input.length();
- if(length > 10) {
- length = 10;
- }
- // Erstmal nach Fehlern in der Eingabe suchen
- // Dazu iterieren wir über den Eingabestring, d.h. wir schauen uns jeden Buchstaben
- // genau an.
- for (int position = 0; position < length; position++) {
- String letter = input.substring(position, position+1);
- // Der komplizierte Ansatz /*
- if( letter.equals("0") || letter.equals("1") || letter.equals("2") ||
- letter.equals("3") || letter.equals("4") || letter.equals("5") ||
- letter.equals("6") || letter.equals("7") || letter.equals("8") ||
- letter.equals("9"))
- {
- continue;
- }
- // An diese Stelle kommen wir nur, wenn die Eingabe nicht 012345678 oder 9 war
- System.out.println("Could not parse input string. Only numbers allowed!");
- System.exit(-1);
- // */
- // Der kürzere, aber für euch noch unbekannte Weg. Also kinda hacky.
- /*
- // Versuche den Buchstaben an dieser Stelle zu einem Integer zu machen
- // Falls das fehlschägt, Fehler ausgeben und beenden.
- try {
- Integer.parseInt(letter);
- } catch (Exception e) {
- System.out.println("Could not parse input string. Only numbers allowed!");
- System.exit(-1);
- }
- */
- }
- // position is X
- // row is Y
- for (int row = 0; row < zahlen[0].length; row++) {
- for (int position = 0; position < length; position++) {
- //int number = Integer.parseInt(input.substring(position, position+1));
- int number = getIntAt(input, position);
- System.out.print(zahlen[number][row]);
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement