'Money wanted' algorithm (OOP version)

Quote
>> I  need alot of money badly; Could anyone help?
>Program Make_Money;

>Uses Nothing;
>begin
>  Repeat
>    Find(EmptyCoffeeCup);
>    Find(BusyStreet);
>    Repeat
>      Sit(MiddleOfStreet)
>    Until Sun(Down)
>  Until Hell(FrozenOver)
>end.

You might as well use objects... they are definitely the way to go:

type loser=object
            money:integer;       {Need a signed variable in case of robbery}
            intelligence:byte;   {doesn't need to be very big}
            constructor stupidity;
            destructor death;
           end;
     wanna_be=object(loser)
            hit_points:shortint; {doesn't need to be very big either}
            coffee_cup:boolean;
            SunUp:boolean;
            CauseOfDeath:byte;
            constructor stupidity;
            destructor death;
            procedure run;  {Was: runForYourLife.. but name was too long}
           end;

constructor loser.stupidity;
begin
 money:=0;
 intelligence:=0;
end;

destructor loser.death;
begin
{Adjust money .. take into account the amount the government takes away upon
death}
 money:=-maxint;
end;

constructor wanna_be.stupidity;
begin
 inherited stupidity;   {boy, is this probably the truth.}
 coffeeCup:=0;
 hit_points:=5;         {+3 bonus for cup of coffee.. need to implement}
                        {wanna_be.CheckForCaffeine}
end;

destructor wanna_be.death;
begin
 inherited death;
 case CauseOfDeath of
  0:writeln('You died of starvation on level 1.');
  1:writeln('You have been beaten to death by a little old lady.');
  3:writeln('You have been run over.  It isn''t pretty.');
  4:writeln('core dump, your fault.');
  5:begin
     writeln('You've been bitten and drained of {*word*76}.');
     if SunUp then writeln('You''d better start looking for a dark place');
    end;
  else
   writeln('You''re just a loser baby, that''s why somebody killed you.');
  end;
end;

procedure wanna_be.run;
begin
 repeat
  while (money<>enough) and (SunUp) do
    inc(money,coffeecup);
 until Hit_points<0;
end;

var you:^Wanna_be;

begin
 new(you,stupidity);
 you^.run;
 dispose(you,death);
end.

--Mark Iuzzolino
One of the monst...@monstersoft.com    | "When we're not coding we're
http://www.monstersoft.com             |  eating the furniture."