From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=BAYES_50,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ffff5,c9f74105f42d0d7,start X-Google-Attributes: gidffff5,public X-Google-Thread: 109fba,c9f74105f42d0d7,start X-Google-Attributes: gid109fba,public X-Google-Thread: 111d6b,c9f74105f42d0d7,start X-Google-Attributes: gid111d6b,public X-Google-Thread: fdb77,c9f74105f42d0d7,start X-Google-Attributes: gidfdb77,public X-Google-Thread: 103376,c9f74105f42d0d7,start X-Google-Attributes: gid103376,public X-Google-Thread: 109d99,c9f74105f42d0d7,start X-Google-Attributes: gid109d99,public X-Google-Thread: 10baee,c9f74105f42d0d7,start X-Google-Attributes: gid10baee,public X-Google-Thread: 1108a1,c9f74105f42d0d7,start X-Google-Attributes: gid1108a1,public From: monsters@nmia.com (MonsterSoft) Subject: Re: 'Money wanted' algorithm (OOP version) Date: 1996/12/31 Message-ID: <5abk5g$ils@hume.nmia.com>#1/1 X-Deja-AN: 206973767 organization: NMIA newsgroups: comp.lang.c++,comp.lang.ada,comp.lang.java.advocacy,comp.lang.java.misc,comp.lang.pascal.delphi.components.misc,comp.lang.pascal.delphi.databases,comp.lang.pascal.delphi.misc,comp.object Date: 1996-12-31T00:00:00+00:00 List-Id: >> 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."