Flatworms are hermaphroditic with both male and female reproductive organs. They also have internal fertilization. See Penis Fencing (Behavior Sequences) to learn how the sperm gets delivered.
Flatworm Animation: Reproduction
Next Generation Science Standards for this Video
Flatworms have an elaborate reproductive system with both female and male organs in the same animal which is called hermaphrodism. Being hermaphroditic optimizes the chances of reproducing if encountering another of your own kind is a rare event.