Implementing quantum gates through scattering between a static and a flying qubit