From: Mohit Sindhwani Date: 2007-11-04T05:09:43+09:00 Subject: Re: dragons and factorials (keyboard input) Might I recommend that you read a book about Ruby and/ or programming (I think Ruby). In either case, reading Chris Pine's "How to Program" will give you all that you need to know about walking - and I think you'll be able to run after that. Things like to_i and to_s, etc. are quite elementary to any language and are covered in detail in books about the language. Cheers, Mohit. 11/4/2007 | 4:08 AM. Thufir wrote: > I googled, didn't find the answer, posted, googled more, found the > answer: > > C:\code> > C:\code> > C:\code> > C:\code> > C:\code>type makeDragon.rb > require 'Dragon' > require 'factorial' > > aDragon = Dragon.new > > aDragon.toString > > number=0 > print "\n\n\nthe Dragon will calculate a factorial now." > puts "\nenter an integer " > #number=gets > number = gets.chomp.to_i > > # print "\n\n\n" + number + "\n\n" > > answer=fact(number) > print "Dragon replies\n\n" > print answer > #print fact(number) > C:\code> > C:\code>makeDragon.rb > > > > This Dragon > ------------------- > Life: 1340 > Strength: 451 > Charisma: 1020 > Weapon: 939 > > > > > > > the Dragon will calculate a factorial now. > enter an integer > 11 > Dragon replies > > 39916800 > C:\code> > > > > > A bit chagrined, > > Thufir > > > > > > ps: I'm thinking about class, inheritance and so forth. I'm going to > review another thread where I was asking about the ruby equivalent to > "static class methods" for, specifically, the factorial which I want > ensure cannot be instantiated. I know it's an object, because > everything's an object in Ruby, but have to think about that one. > > I think I also want to make some private methods, and a friend was > suggesting to insert some error if the Dragon has low intelligence! :) > > > > >