Message in a Bottle #SongsInCode

Sting

This afternoon I did something extraordinarily productive and created an extended #SongsInCode rendition of Message in a Bottle that compiles. Now all somebody in this distant future needs to do is create a new class to fetch Sting's bottle and read his message!

Sting.java

public class Sting {
  public static void main(String[] args) {
    Bottle oceanBottle = new Bottle("SOS!");
  }
}

Bottle.java

public class Bottle {
  String message = "";
  boolean opened = false;
  public Bottle(String message) {
    this.message = message;
  }
  public void pullCork() {
    opened = true;
  }
  public String getMessage() throws NotOpenException {
    if (opened)
      return message;
    else
      throw new NotOpenException();
  }
}

NotOpenException.java

public class NotOpenException extends Throwable {
  public NotOpenException() {
    super("You haven't opened the bottle yet!");
  }
}

Tagged: software infocomm java memes music pointless twitter

Who wrote this?

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person.

This blog is powered by the excellent FreeBSD and OpenZFS. Also check out BSD Now.

You can buy me a coffee or send a comment if you found this post useful or entertaining. Cheers.