From: August0866 Date: 2008-03-05T04:09:55+09:00 Subject: Re: Class and inheritance On Mar 4, 1:23 pm, Todd Benson wrote: > On Tue, Mar 4, 2008 at 8:50 AM, August0866 wrote: > > OK, 2 dumb questions What is the difference between a class and a > > module and > > > What is wrong here, the logic or the syntax > > > Npc, def => job)> > > > def job > > if > > @power.to_f > 12 && @smarts.to_f > 14 && @speed.to_f > 14 > > @job = 'Adventurer' > > elsif > > @power.to_f > 14 and (@smarts.to_f <14 or @speed.to_f < 14) > > @job = 'laborer' > > elsif > > @power.to_f < 14 and (@smarts.to_f > 14 and @speed.to_f > 14) > > @job = 'coureror' > > elsif > > @power.to_f < 14 and (@smarts.to_f > 14 and @speed.to_f < 14) > > @job='teacher' > > else > > @job = 'commoner' > > end > > end > > > > > the result is sometimes joe is an adventurer otherwise nothing is > > output > > Not sure, but I think the logic. (@smarts.to_f < 14 or @speed.to_f < > 14) will be true the same time (@smarts.to_f > 14 and @speed.to_f < > 14) is true. Your decision set is not mutually exclusive because of > that first 12 (What if your 13?). Just a guess... > > Todd Ok, i'm looking for a true false answer to choose a job. For example Joe - smarts = 15 power = 9 speed = 17 adventurer job needs power >= 12 and speed >=14 and smarts >= 14 ?joe an adventurer = false laborer job needs power >= 12 but smarts and speed <= 12 ?joe laborer = false mailman job needs power >=12 speed >=12 but smarts >=9 ?joe mailman = false teacher job needs power <=14 speed <=14 but smarts >=14 ?joe teacher = D'oh i see the problem..... i need to rethink the jobs