comp.lang.ada
 help / color / mirror / Atom feed
* Re: 'Money wanted' algorithm (OOP version)
@ 1996-12-31  0:00 MonsterSoft
  0 siblings, 0 replies; only message in thread
From: MonsterSoft @ 1996-12-31  0:00 UTC (permalink / raw)



>> 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 blood.');
     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 monsters@monstersoft.com    | "When we're not coding we're
http://www.monstersoft.com             |  eating the furniture."




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-12-31  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-31  0:00 'Money wanted' algorithm (OOP version) MonsterSoft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox