Groan. Are we going to take every college philosophy exercise idea but scratch out "human" and replace it with "robot"?
What next - do we need to program airplanes to crash in order to avoid being used as weapons? Cars programmed to torture people to reveal where the nuclear bomb is hidden?
More useful, (re)read the Asimov robot series and the effects of the zeroth law of robotics.