'Money wanted' algorithm (OOP version) 
Author Message
 '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 {*filter*}.');
     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

http://www.*-*-*.com/             |  eating the furniture."



Sat, 19 Jun 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. type field ''money''

2. ||||| that's how they make money ||||

3. please help me on Djikstra's Algorithm

4. Pascal code for Dijkstra's algorithm

5. please help me on Djikstra's Algorithm

6. please help me on Djikstra's Algorithm !!

7. money, money, money

8. Delphi's interface with Informix )n-Line Dyanamic Server (version 7.1)

9. ******** Automatic Version Control System (I/A's etc) ********

10. ******** Automatic Version Control System (I/A's etc) ********

11. IndexDefs.Add('Help','Please',[ixD2WorksGreat, ixD3Errors])

12. WANTED manual Borland INTERBASE Programmer's Guide

 

 
Powered by phpBB® Forum Software