19
$\begingroup$

The following is a text rebus in the form of a Java program:

import java.awt.*;

public class WhatIsThis {
    private static Panel panel = new Panel();

    static {
        init();
    }

    public static void main(String[] args) {
        while (panel.getComponentCount()>0) {
            panel.getComponentCount();
            panel.getClass();

            panel.getComponentCount();

            Container c = (Container)panel.getComponent(0); panel.remove(c);

            method1(c);

            panel.getComponentCount();
            panel.getClass();
        }

        /*
        // OPTIONAL:

        panel.getComponentCount();
        panel.getClass();

        panel.getComponentCount();

        init();

        panel.getComponentCount();
        panel.getClass();

        main(args);
        */
    }

    private static void init() {
        for (int i=1; i<100; i++) {
            Container c = new Container();
            c.setName("ISB");
            panel.add(c);
        }
    }

    private static void method1(Container c) {
        method2(c);
    }

    private static void method2(Container c) {
        method3(c);
    }

    private static void method3(Container c) {
    }
}

What does it represent? Bonus points if you can figure out what "ISB" means.

$\endgroup$
4
  • 2
    $\begingroup$ ewww...JAVA! Where is the Python and C(++) ;P $\endgroup$
    – Mark N
    Jun 15, 2015 at 13:37
  • 4
    $\begingroup$ Awesome puzzle. I got a kick out of it once I figured it out. $\endgroup$ Jun 15, 2015 at 13:43
  • $\begingroup$ I'm not sure I've ever heard that optional intro before. $\endgroup$ Jun 16, 2015 at 4:28
  • $\begingroup$ @IanMacDonald See BitCoder's answer. $\endgroup$ Jun 16, 2015 at 5:06

2 Answers 2

20
$\begingroup$

I'm fairly certain this is a representation of

"99 Bottles of Beer on the Wall". You add 99 components to a panel, then proceed in a loop to get the count in the panel and then the count again (like in the song), and then remove one and pass it around (into a few methods, lol).

Had to honestly google "ISB", turns out it's

"industry standard bottle", for a bottle of beer. :)

$\endgroup$
6
  • $\begingroup$ I think this seems correct $\endgroup$
    – Mark N
    Jun 15, 2015 at 13:41
  • $\begingroup$ was thinking same . You should add lyrics :) 99-bottles-of-beer.net/lyrics.html $\endgroup$
    – shy
    Jun 15, 2015 at 13:44
  • 7
    $\begingroup$ 99 components inside a panel, 99 components inside! method1(panel.remove(panel.getComponent(0))); 98 components inside the panel!.. $\endgroup$
    – Mark N
    Jun 15, 2015 at 13:51
  • 1
    $\begingroup$ @MarkN Your code actually won't work because panel.remove(...) doesn't return anything. $\endgroup$ Jun 15, 2015 at 16:10
  • 1
    $\begingroup$ It should also be noted that the puzzle used Containers. A beer bottle is a type of container, and of course "ISB" was used to indicate that. $\endgroup$ Jun 16, 2015 at 5:28
3
$\begingroup$

The optional section, as shyos said, states there are 0 bottles on the wall, puts 99 bottles of beer back on the wall, and then sings the song again:

panel.getComponentCount(); = No more bottles of beer
panel.getClass(); = on the wall

panel.getComponentCount(); = No more bottles of beer

init(); = Go to the store and buy some more

panel.getComponentCount(); = 99 bottles of beer
panel.getClass(); = on the wall

main(args); = repeat song and eventually crash (due to stack overflow), which is pretty much what a person would do if they had to sing the song over and over and over...

Note from OP: The lyrics for the optional section can be found in the book 99 Bottles of Beer on the Wall: The Complete Lyrics by Tim Nyberg (2006).

$\endgroup$
3
  • 2
    $\begingroup$ well actually optinal part is in the main. so once song(while) ends, optinal part states there is 0 bottle on the wall and then puts 99 bottles back to wall and sings the song again. $\endgroup$
    – shy
    Jun 15, 2015 at 14:11
  • $\begingroup$ You got the "on the wall" parts right, though. I wanted to differentiate between the "N bottles of beer on the wall" and "N bottles of beer" lines. I'm going to fix up the rest of your answer. $\endgroup$ Jun 16, 2015 at 4:53
  • $\begingroup$ "No more bottles of beer class javax.swing.JPanel! No more bottles of beer! Go to the store and buy some more, 99 bottles of beer class javax.swing.JPanel!" $\endgroup$
    – user253751
    Jun 16, 2015 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.