Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
in the main package,

# join the people threads and collect statistics my ($total_wait, $total_ride, $max_wait, $max_ride) = (0,0,0,0); foreach (@people) { my ($wait1, $wait2, $ride1, $ride2) = $_->join; $total_wait += $wait1 + $wait2; $total_ride += $ride1 + $ride2; $max_wait = $wait1 if $wait1 > $max_wait; $max_wait = $wait2 if $wait2 > $max_wait; $max_ride = $ride1 if $ride1 > $max_ride; $max_ride = $ride2 if $ride2 > $max_ride; }
is shorter and more clearly written as:

# join the people threads and collect statistics my ($total_wait, $total_ride, $max_wait, $max_ride) = (0,0,0,0); foreach (@people) { my ($wait1, $wait2, $ride1, $ride2) = $_->join; $total_wait = $wait1 + $wait2; $total_ride = $ride1 + $ride2; $max_wait = $wait1 > $wait2 ? $wait1 : $wait2; $max_ride = $ride1 > $ride2 ? $ride1 : $ride2; }
in the Elevator class, the constant STARTING is declared and never used.

as an aside: in new york city, there are three buildings with double-decker elevators (i've worked in two of them.) lobby and mezzanine are the base levels, and when going up you must use the lobby for odd floors (L 3 5 7 ... ) and mezzanine for odd floors (M 4 6 8 ...). going down, you can reach any floor from either level (except the edge case at the bottom.) i believe the Elevator class can be easily subclassed to handle this scenario as well. cool.

~Particle *accelerates*


In reply to Re: Multi-Threaded Elevator Simulator by particle
in thread Multi-Threaded Elevator Simulator by samtregar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-20 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found