YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← driveCars - Intro to Java Programming

Get Embed Code
4 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

  1. There are many ways of doing this, here is one that I think is fairly simple.
  2. Let's look at the inner loop first. So we want to go through all of the cars
  3. and drive them. And we want to keep doing that until all of the cars have
  4. reached their destination and that's the challenging part. All of the cars
  5. started at location zero and then they moved to location one. And now maybe
  6. this one here doesn't need to go any further. And I need to, have to have some
  7. way of stopping this car from moving. So what I'm simply going to do is I'm
  8. going to remove him from the list of cars. So that's the part here. If this car
  9. has arrived, then I'll just remove that car. And remember, when I remove an
  10. element from the array list, then I don't reccomend the index. But I do it over
  11. here. And I keep doing that while I have cars to drive.