Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lwp.ejemplos;
- import java.io.IOException;
- public class Misil{
- private static final String cohete[] = {" /|\\ ",
- " |B| ",
- " |O| ",
- " |M| ",
- " |B| ",
- " //|\\\\ ",
- " ******* ",
- "* * * * *",
- " * * * * "};
- private static final int estado[] = {3, 2, 1, 2, 3, 4};
- public static void main(String args[]){
- System.out.println("Presione una tecla para iniciar el lanzamiento");
- try{
- System.in.read();//TODO: Pausar el lanzamiento hasta que se presione una tecla.
- }catch(IOException e){}
- primeraParte();
- segundaParte();
- ultimaParte();
- }
- private static void primeraParte() {
- for(int i = 1; i <= 11; i++){
- for(int j = 1; j <= 15; j++){
- System.out.println("");
- }
- for(int j = 0; j < 6; j++){
- System.out.println(cohete[j]);
- }
- System.out.println();
- System.out.println("Lanzamiento en " + (11 - i));
- try {
- Thread.sleep(1000);//Esperar un segundo.
- }catch(InterruptedException ex){}
- }
- }
- private static void segundaParte() {
- for(int i = 1; i <= 15; i++) {
- for(int j = i; j <= 15; j++) {
- System.out.println("");
- }
- for(int j = 0; j < cohete.length - 1; j++) {
- System.out.println(cohete[j]);
- }
- if(i > 1) {
- System.out.println(cohete[cohete.length - 1]);//Ultima posición
- }
- try{
- Thread.sleep(1000 / i);
- }catch(InterruptedException e){}
- }
- }
- private static void ultimaParte() {
- for(int i = 1; i <= 10; i++) {
- for(int j = 0; j < estado.length; j++) {
- estado[j] = estado[j] - 1;
- switch(estado[j]) {
- case 0:
- cohete[j] = " + ";
- break;
- case 1:
- case 5:
- cohete[j] = " +X+ ";
- break;
- case 2:
- case 4:
- cohete[j] = " +XXX+ ";
- break;
- case 3:
- cohete[j] = " +XXXXX+ ";
- break;
- case 6:
- cohete[j] = " ";
- break;
- }
- System.out.println(cohete[j]);
- }
- try{
- Thread.sleep(200);
- }catch(InterruptedException e){}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement