InceptionException

Bien, en algo vamos a estar de acuerdo desde el principio: esto es algo muy geek. Lo siento, una parte de mi, muy muy oculta, entiende estas cosas.
Luego, esta es una fumada que se me ocurrió durante mi curso de JAVA después de haber visto la película. Es sólo una representación estúpida de lo que entendí que sucede con el protagonista y su chica MALvada.
Siguiente, necesitas haber visto la película Inception (El Origen), porque si no, no le vas a entender.
Además, necesitas conocer el lenguaje de programación JAVA, si no, tampoco te va a hacer mucha gracia.
Opcionalmente podrías compilar tu mismo la clase, pero no lo hagas, ya suficiente tiempo he perdido yo en esta estupidez y quiero ahorrártelo.
Continuando, si eres del selecto grupo que llegó hasta el final y entendió un poco de todo esto y le causó gracia, me sentiré menos estúpido.
Por último, este es un malviaje muy “geek”, trataré de no hacerlo en un muy buen rato. Intenté contenerme, de verdad ja ja ja! Además de que cuesta mucho trabajo escribir código de esta manera…

P.D. Obviamente si hay algo que no está bien implementado en JAVA o entendí mal en la película o tienen una mejor idea, se aceptan sugerencias.
P.D.2 Gracias por su amable, geek, y atenta atención 😉 … De todos modos como siempre les digo, nunca brillaremos en sociedad, ja ja ja!

import java.util.Stack;

public class InceptionExample {

   public static void main(String[] args)
   {
       Dreamer Cobb = new Dreamer("Cobb");
       Dreamer Mal = new Dreamer("Mal");
       //Normal Dreaming
       Cobb.fallAsleep("Normal Dream but...");
       Mal.fallAsleep("Normal Dream but...");
       //Lets dream together
       Cobb.fallAsleep("... why not a Beautiful Dream...");
       Mal.fallAsleep("... why not a Beautiful Dream...");
       //Lets dream together about living together
       Cobb.fallAsleep(".. or perhaps a whole life with your significant other!");
       Mal.fallAsleep(".. or perhaps a whole life with your significant other!");
       //This is not real, we got to wake up
       Cobb.getKicked();
       Mal.getKicked();
       //Mal is not quite convinced...
       Cobb.getKicked();
       Mal.getKicked();
       //What if everything is a dream?
       Cobb.getKicked();
       Mal.getKicked();
       //No! Mal!! what are you doing!!!?
       System.out.println("No! Mal!! what are you doing!!!?");
       Mal.getKicked();
   }
}

class Dreamer
{
   private String name = "";
   private Stack<String>dreamLayers;

   /**
     * This is like get born, gives you the base layer, The Real Life
    */
   public Dreamer(String name)
   {
       this.name = name;
       dreamLayers = new Stack<String>();
       System.out.println(name + " was born");
   }
   /**
     * This method is used when the dreamer wants to get out of the dream
     * it is fired when the dreamer gets the sensation of falling in the immediate
     * upper layer... or kills him/herself in the current layer...
    */
   public void getKicked()
   {
       System.out.println(name + ": you are about to end your dream in the layer: " +
         (dreamLayers.size()==0?"Real life":dreamLayers.get(dreamLayers.size()-1)));
       String currentLayer = dreamLayers.pop();
   }

   /**
     * Fall asleep in the current layer, that gets you into an inner layer
     * time passes faster on the inner layers, so 1 sec in one layer may mean 10 minutes in other and so on...
     * Sorry... haven't the exact number.
    */
   public void fallAsleep(String dream)
   {
       //System.out.println(name + ": you are about to enter to the layer: " + dream);
       dreamLayers.push(dream);
       System.out.println(name + ": you are now in the layer: " + dream);
   }
}

Ahí está la clase.
Y para los que no quieran compilarla, la salida:

Cobb was born
Mal was born
Cobb: you are now in the layer: Normal Dream but…
Mal: you are now in the layer: Normal Dream but…
Cobb: you are now in the layer: … why not a Beautiful Dream…
Mal: you are now in the layer: … why not a Beautiful Dream…
Cobb: you are now in the layer: … or perhaps a whole life with your significant other!
Mal: you are now in the layer: … or perhaps a whole life with your significant other!
Cobb: you are about to end your dream in the layer: … or perhaps a whole life with your significant other!
Mal: you are about to end your dream in the layer: … or perhaps a whole life with your significant other!
Cobb: you are about to end your dream in the layer: … why not a Beautiful Dream…
Mal: you are about to end your dream in the layer: … why not a Beautiful Dream…
Cobb: you are about to end your dream in the layer: Normal Dream but…
Mal: you are about to end your dream in the layer: Normal Dream but…
No! Mal!! what are you doing!!!?
Mal: you are about to end your dream in the layer: Real life
Exception in thread “main” java.util.EmptyStackException

You may also like...

1 Response

  1. Gerardo says:

    Llevame a miiiiiiiiiiiiiiii, le hemos perdido, jajajajajajajaja

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.