MrDoyle

Methods) Flicker Phrase

Apr 9th, 2021
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class Main
  4. {
  5.     public static void main( String[] args ) throws InterruptedException {
  6.         Random rng = new Random();
  7.         int r;
  8.  
  9.         for ( int i=0; i<10000; i++ ) {
  10.  
  11.             r = 1 + rng.nextInt(6);
  12.             if(r==1){
  13.                first();
  14.             } else if (r==2){
  15.                 second();
  16.             } else if(r==3){
  17.                 third();
  18.             } else if (r==4){
  19.                 fourth();
  20.             } else{
  21.                 fifth();
  22.             }
  23.  
  24.             Thread.sleep(1);
  25.         }
  26.  
  27.         System.out.println("I pledge allegiance to the flag.");
  28.  
  29.     }
  30.  
  31.     public static void first()
  32.     {
  33.         System.out.print("I                               \r");
  34.     }
  35.  
  36.     public static void second()
  37.     {
  38.         System.out.print("  pledge                        \r");
  39.     }
  40.  
  41.     public static void third()
  42.     {
  43.         System.out.print("         allegiance             \r");
  44.     }
  45.  
  46.     public static void fourth()
  47.     {
  48.         System.out.print("                    to the      \r");
  49.     }
  50.  
  51.     public static void fifth()
  52.     {
  53.         System.out.print("                           flag.\r");
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment