Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Chains {
  5.    
  6.     public static void main (String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.         System.out.println("Bitte wählen Sie zunächst, welche Zeichenkette sie bilden wollen und geben Sie anschließend die Ordnung oder die Länge der Kette an. ");
  9.         System.out.println("| C für Charchain | \t D für Dragonchain | \t L für LevyC ");
  10.        
  11.         String userinput = input.nextLine();
  12.         if(userinput.equals("C")) {
  13.             charChain(int k);
  14.         } else if(userinput.equals("D")) {
  15.             dragonChain(int k);
  16.         } else if(userinput.equals(int k)) {
  17.             levyC(int k);
  18.         } else {
  19.             System.out.println("Fehler bei Eingabe: Ungültiger Aufruf");
  20.         }
  21.     }
  22.  
  23.     public static void charChain(int k) {
  24.         if(k > 0 || k <= 100000) {
  25.             char[] chars = new char[];
  26.             char chars[] = {'F','R','L'};
  27.             System.out.printf("Laenge k der Zeichenkette: %c\n", k);
  28.            
  29.             for(int i = 0; i < chars.length; i++) {
  30.                 System.out.printf("%c", chars[StdRandom.uniform[3]]);
  31.             }
  32.         } else {
  33.             System.out.println("Fehler: Die Laenge k der Zeichenkette darf nur zwischen 0 und 100001 liegen.");
  34.         }  
  35.     }
  36.    
  37.     public static void dragonChain(int k) {
  38.         if(k > 20 && k < 0) {
  39.            
  40.             int length = (int) Math.pow(2,k + 1) - 1;
  41.             char[] dragon = new char[length];
  42.            
  43.             dragon[0] = 'F';
  44.             System.out.print(dragon[0]);
  45.            
  46.             for(int i = 1; i < length; i++) {
  47.             if(dragon[i - 1] == 'F')
  48.                 int random = StdRandom.uniform(2);
  49.                
  50.                 if(dragon[i] == 0) {
  51.                     dragon[i] = 'R';
  52.                 } else {
  53.                     dragon[i] = 'L';
  54.                 }
  55.             }else {
  56.                 dragon[i] = 'F';
  57.             }
  58.         } else {
  59.             System.out.println("Fehler");
  60.         }
  61.        
  62.         for(int i = 1; i < length; i++){
  63.             System.out.printf("%c", dragon);
  64.         }
  65.        
  66.         System.out.println("Die Länge der Zeichenkette ist:" + length);
  67.     }
  68.    
  69.     public static void levyC(int k) {
  70.         if(k > 20 && k < 0) {
  71.            
  72.             char[] levy = new char[];
  73.             char levy[] = {'F','+','-'};
  74.            
  75.             for(int = 0; i <= k; i++) {
  76.                 if(i == 0) {
  77.                     levy[0] = 'F';
  78.                 } else {
  79.                     hilfsMethodeL(char[] levy);
  80.                 }  
  81.             }  
  82.         } else{
  83.             System.out.println("Fehler");
  84.         }
  85.     }
  86.    
  87.     public static void hilfsMethode(int i) {
  88.         if(i == 0){
  89.             return "i";
  90.         } else {
  91.             return;
  92.         }      
  93.     }
  94.    
  95.     public static void hilfLevyC (char[] levy){
  96.         char[] levyH = new char[2 * levy.length + 4];
  97.        
  98.         levyH[0] = '+';
  99.        
  100.         for(int j = 1; j <= levyH.length; j++) {
  101.             for(int i = 0; i <= levy.length; i++) {
  102.                 levyH[j] = levy[i];
  103.             }
  104.             levyH[levy.length + 1] = '-';
  105.             levyH[levy.length + 2] = '-';
  106.         }
  107.         levyH[0] = '+';
  108.     }
  109.    
  110.     public static void umwandeln(char[] levy) {
  111.        
  112.     }  
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement