Train Puzzle

The red engine can travel through the yellow tunnel but neither the blue nor the green car can. Use the red engine to switch the positions of the two cars and have the engine return to its original starting position.

Java Source