Advertisement
Guest User

Misil.java

a guest
Dec 8th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. package com.lwp.ejemplos;
  2.  
  3. import java.io.IOException;
  4.  
  5. public class Misil{
  6.     private static final String cohete[] = {"   /|\\   ",
  7.                         "   |B|   ",
  8.                         "   |O|   ",
  9.                         "   |M|   ",
  10.                         "   |B|   ",
  11.                         "  //|\\\\  ",
  12.                         " ******* ",
  13.                         "* * * * *",
  14.                         " * * * * "};
  15.     private static final int estado[] = {3, 2, 1, 2, 3, 4};
  16.  
  17.     public static void main(String args[]){
  18.         System.out.println("Presione una tecla para iniciar el lanzamiento");
  19.         try{
  20.             System.in.read();//TODO: Pausar el lanzamiento hasta que se presione una tecla.
  21.         }catch(IOException e){}
  22.         primeraParte();
  23.         segundaParte();
  24.         ultimaParte();
  25.     }
  26.    
  27.     private static void primeraParte() {
  28.         for(int i = 1; i <= 11; i++){
  29.             for(int j = 1; j <= 15; j++){
  30.                 System.out.println("");
  31.             }
  32.             for(int j = 0; j < 6; j++){
  33.                 System.out.println(cohete[j]);
  34.             }
  35.             System.out.println();
  36.             System.out.println("Lanzamiento en " + (11 - i));
  37.             try {
  38.                 Thread.sleep(1000);//Esperar un segundo.
  39.             }catch(InterruptedException ex){}
  40.         }
  41.     }
  42.    
  43.     private static void segundaParte() {
  44.         for(int i = 1; i <= 15; i++) {
  45.             for(int j = i; j <= 15; j++) {
  46.                 System.out.println("");
  47.             }
  48.             for(int j = 0; j < cohete.length - 1; j++) {
  49.                 System.out.println(cohete[j]);
  50.             }
  51.             if(i > 1) {
  52.                 System.out.println(cohete[cohete.length - 1]);//Ultima posición
  53.             }
  54.             try{
  55.                 Thread.sleep(1000 / i);
  56.             }catch(InterruptedException e){}
  57.         }
  58.     }
  59.    
  60.     private static void ultimaParte() {
  61.         for(int i = 1; i <= 10; i++) {
  62.             for(int j = 0; j < estado.length; j++) {
  63.                 estado[j] = estado[j] - 1;
  64.                 switch(estado[j]) {
  65.                     case 0:
  66.                         cohete[j] = "    +    ";
  67.                         break;
  68.                     case 1:
  69.                     case 5:
  70.                         cohete[j] = "   +X+   ";
  71.                         break;
  72.                     case 2:
  73.                     case 4:
  74.                         cohete[j] = "  +XXX+  ";
  75.                         break;
  76.                     case 3:
  77.                         cohete[j] = " +XXXXX+ ";
  78.                         break;
  79.                     case 6:
  80.                         cohete[j] = "         ";
  81.                         break;
  82.                 }
  83.                 System.out.println(cohete[j]);
  84.             }
  85.             try{
  86.                 Thread.sleep(200);
  87.             }catch(InterruptedException e){}
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement