sim - #!/usr/bin/env ruby # # CMSC330 Project 6:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#!/usr/bin/env ruby ############################################################ ### CMSC330 Project 6: Multi-threaded Train Simulation ### ### Source code: sim.rb ### ############################################################ require "metro.rb" Thread.abort_on_exception = true # to avoid hiding errors in threads # read command line and decide on display(), verify() or simulate() $simFileHeaders = ["=== Lines ===", "=== Trains ===", "=== Passengers ===", "=== Output ===" ] def readParams(fname,lines,numTrains,passengers,simOut) begin f = File.open(fname) rescue Exception => e puts e exit(1) end headerLines = $simFileHeaders[0] headerTrains = $simFileHeaders[1] headerPassenger = $simFileHeaders[2] headerOutput = $simFileHeaders[3] section = nil f.each_line{|line| line.chomp! line.strip! if line == "" || line =~ /^%/ elsif line == headerLines || line == headerTrains || line == headerPassenger || line == headerOutput section = line elsif section == headerLines
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

sim - #!/usr/bin/env ruby # # CMSC330 Project 6:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online