T
Thufir
I want to not just create Dragons, but randomly other creatures.
Perhaps from a hard coded list? I was thinking of using random
numbers and case statements, but surely there's ruby-esque way to
specify:
types of creatures:
AssistantViceTentacleAndOmbudsman.rb
Dragon.rb
IntrepidDecomposedCyclist.rb
TeethDeer.rb
and then (pseudo-) randomly select one to instantiate? Symbols seem
promising but I'm not sure how to implement it.
C:\code>
C:\code>
C:\code>type Driver.rb
require 'ArrayOfCreatures'
require 'Dragon'
require 'Creature'
#numOfCreatures=Kernel.rand(3)
puts "\nquantity of creatures:"
numOfCreatures = gets.chomp.to_i
someCreatures = ArrayOfCreatures.new #need to ensure that this array
can only hold Creatures
0.upto(numOfCreatures) do |i|
someCreatures=Dragon.new #all dragons? what about
TeethDeer's?
print "\n"
print "someCreatures["
print i
print "]:\n"
print someCreatures.toString
end
C:\code>
thanks,
Thufir
Perhaps from a hard coded list? I was thinking of using random
numbers and case statements, but surely there's ruby-esque way to
specify:
types of creatures:
AssistantViceTentacleAndOmbudsman.rb
Dragon.rb
IntrepidDecomposedCyclist.rb
TeethDeer.rb
and then (pseudo-) randomly select one to instantiate? Symbols seem
promising but I'm not sure how to implement it.
C:\code>
C:\code>
C:\code>type Driver.rb
require 'ArrayOfCreatures'
require 'Dragon'
require 'Creature'
#numOfCreatures=Kernel.rand(3)
puts "\nquantity of creatures:"
numOfCreatures = gets.chomp.to_i
someCreatures = ArrayOfCreatures.new #need to ensure that this array
can only hold Creatures
0.upto(numOfCreatures) do |i|
someCreatures=Dragon.new #all dragons? what about
TeethDeer's?
print "\n"
print "someCreatures["
print i
print "]:\n"
print someCreatures.toString
end
C:\code>
thanks,
Thufir