/*
 Supplies the title, author and lyrics to "99 bottles of beer".
*/

function NinetyNineBeers() {

  // Returns the song title
  this.title = function () {
    return "99 Bottles of Beer";
  }
  
  // Returns the song author
  this.author = function () {
    return "Anon";
  }

  // Returns the song lyrics
  this.lyrics = function () {  

    // Unique lyric lines
    var lines = [
      "? bottles of beer on the wall, ? bottles of beer.",
      "1 bottle of beer on the wall, 1 bottle of beer.",
      "No more bottles of beer on the wall, no more bottles of beer.",
      "Take one down and pass it around, ? bottles of beer on the wall.",
      "Take one down and pass it around, 1 bottle of beer on the wall.",
      "Take one down and pass it around, no more bottles of beer on the wall.",
      "Go to the store and buy some more, ? bottles of beer on the wall."
    ];

    // The array to contain the lyrics
    var result = [];

    // The regular expression, to substitute '?'
    var re = /\?/g

    // Couplets 1 to 97: "99 bottles..." to "3 bottles..."
    for (var i = 99; i > 2; i--) {
      result.push(lines[0].replace(re, i.toString()));
      result.push(lines[3].replace(re, (i - 1).toString()));
      result.push("");
    }

    // Couplet 98: "2 bottles..."
    result.push(lines[0].replace(re, "2"));
    result.push(lines[4]);
    result.push("");

    // Couplet 99: "1 bottle..."
    result.push(lines[1]);
    result.push(lines[5]);
    result.push("");

    // Couplet 100: "No bottles..."
    result.push(lines[2]);
    result.push(lines[6].replace(re, "99"));
    return result;
  }
}