Sha256: 23c171fea52596fd9341b4538104792179e098977e6dae0b457fd735faeefc0c
Contents?: true
Size: 606 Bytes
Versions: 1
Compression:
Stored size: 606 Bytes
Contents
import java.util.ArrayList class Door :state def initialize @state=false end def closed?; !@state; end def open?; @state; end def close; @state=false; end def open; @state=true; end def toggle if closed? open else close end end def toString; Boolean.toString(@state); end end doors=ArrayList.new 1.upto(100) do doors.add(Door.new) end 1.upto(100) do |multiplier| index = 0 doors.each do |door| Door(door).toggle if (index+1)%multiplier == 0 index += 1 end end i = 0 doors.each do |door| puts "Door #{i+1} is #{door}." i+=1 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mirah-0.0.8-java | examples/rosettacode/100-doors.mirah |