[Prev][Next][Index][Thread]

Re: Exceptions help please!



I found this on a website and was hoping that someone could help me with an
exception for it.
I've tried to work it out, but have been unable to identify it.
The exception I'm after needs to catch invalid data like when a letter is
used in the call to beer instead of a number.

// Dylan version of 99 Bottles of Beer
// programmer: Jim Studt jim@federated.com

define method enumerate( count == 1 ) "1 bottle" end method enumerate;
define method enumerate( count == 0 ) "no more bottles" end method
enumerate;
define method enumerate( count :: <integer> )
  format-to-string("%d bottles", count);
end method enumerate;

define method reference( count == 1) "it" end method reference;
define method reference( count :: <integer>) "one" end method reference;

define method beer (argv0, #rest noise)
  for ( i from argv0 to 1 by -1)     // I have modified this to argv0 from
99
    format( *standard-output*, "%s of beer on the wall, %s of beer.\n",
    enumerate(i), enumerate(i));
    format( *standard-output*,
    "  Take %s down, pass it around, %s of beer on the wall.\n",
    reference(i), enumerate( i - 1));
  end for;
end method beer;


Thanks for your assistance
Daniel Butun





Follow-Ups: