On Wed, Aug 18, 2010 at 1:57 PM, Bruce Wayner <winshocker / gmail.com> wrote:
> can someone edit my code:
> i've been trying to change the thing you said but it shows nothing. :(

> print "Number of Vehicle: " #That will be maximum of 5 only
> n =3D gets().to_i

START DELETE
> print "\n Vehicle number 1: "
> =A0$delay1 =3D rand(4)
> =A0$delay2 =3D rand(10)
> =A0$departure_Time =3D rand(36)
> =A0$travel_Time=3D rand(71)
>
> =A0$delay1 +=3D1
> =A0sleep($delay1)
> =A0sleep($delay2)
> =A0$passenger2=3D 1
> =A0$delay101 =3D rand(10)
> =A0puts ("\nDeparture Time: =A0#$departure_Time seconds");
> =A0puts ("Traveling Time: =A0#$travel_Time seconds");
> =A0puts ("# of passenger Arrive in Second City: #{$passenger2}");
> =A0puts ("Total Traveling Time: =A0 =A0 #{$delay1} seconds");
> =A0$i =3D 1+1;
END DELETE

Add: $i =3D 1

> =A0$num =3D n+1;
>
> =A0while $i < $num =A0do
>
> =A0puts ("\n Vehicle number: #{$i}");
> =A0$i +=3D1;
>
> =A0$departure_time2 =3D rand(36)
> =A0$travel_time2 =3D rand(71)
> =A0$passenger1=3D2
> =A0 =A0 puts ("\nDeparture Time: =A0#$departure_time2 seconds");
> =A0 =A0 puts ("Traveling Time: =A0#$travel_time2 seconds");
> =A0 =A0puts ("# of people Arrive in second city: #{$passenger1}");
> =A0 =A0puts ("Total Traveling Time: =A0#$totalTravel");
>
> =A0end
> =A0puts("# of people transfer:");
> =A0puts("Total Time:");

That's a start to cut down the amount of code you have to deal with
and still give pretty much the same result.