The ping pong ball will bounce off the ceiling of the train car unless it's a very, very tall train, so the surface of the maching that bounces the ping pong ball has to be perfectly in plane with the ceiling, the ceiling has to be perfectly flat, and the train needs to be perfectly level. The ball will hit the ceiling and bounce back at a much faster rate than if it were ascending into the air and slowing down to zero before starting to descend and speeding up due to gravity, so it'll basically be bouncing between the ceiling and your machine at a very high rate of speed, just like in a game of pong when the ball gets trapped between the paddle and a wall.