Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Chrome

Date:04/19/06
Author:Christian Meurin
URL:n/a
Comments:2
Info:http://www.chromesville.com/index.asp
Score: (2.20 in 5 votes)
(* Chrome is an Object Pascal variant that runs on the .NET
   platform. It is inspired by Delphi.NET and adds several
   new language features.

   Although a Chrome application normally includes an
   AssemblyInfo.pas file, I felt it was insignificant for
   a 99 Bottles of Beer example.

   This example utilizes Chrome v1.5, which can be found at:
   http://www.chromesville.com/index.asp
*)

namespace BottlesOfBeer;

interface

uses
  System; // from the .NET framework that is...

type
  LetsStartChugging = public class
  {$REGION Declarations} // Not necessary, just for show off
  public
    constructor;
    class method Main(Args: array of String);
  end;
  {$ENDREGION}

implementation

constructor LetsStartChugging;
begin
  // Does nothing, but just shows how Chrome constructors are used.
end;

[STAThread] // Apparently needed for .NET application Main method
class method LetsStartChugging.Main(Args: array of String);
var
  GotAlcoholPoisoning: Boolean;
  BeerStock: Integer;
begin
  for BeerStock := 99 downto 0 do begin
    if BeerStock > 1 then begin
      Console.WriteLine(BeerStock + ' bottles of beer on the wall,');
      Console.WriteLine(BeerStock + ' bottles of beer.');
    end
    else begin
      Console.WriteLine('One more bottle of beer on the wall,');
      Console.WriteLine('One more bottle of beer.');
    end

    Console.WriteLine('Take one down, pass it around,');

    if BeerStock = 1 then begin
      Console.WriteLine('One more bottle of beer on the wall.');
    else begin
      Console.WriteLine(BeerStock + ' more bottles of beer on the wall.');
    end
  end

  Console.WriteLine('<passes out from drinking too much>');
end

end.

Download Source | Write Comment

Alternative Versions

Comments

>>  Chris said on 04/19/06 16:14:10

Chris Whoops, I have an unused boolean variable in there. :-\

>>  vakninir said on 04/29/09 23:37:55

vakninir you have an error...
because the 'BeerStock' goes down only when he gets to the for...
it will cause the next situation:

"99 bottles of beer on the wall, 99 bottles of beer
you take one down, pass it around, 99 bottles of beer on the wall"

it take the count down only every new line... which is not good...
plus u do waaaaay to much newline... but that's not really a problem...

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: