And how do you deal when someone felt sick inside a toilet? Or when a little child locked himself and can't unlock? Or when someone without a ticket went in?
You add a mechanical override cylinder. Conversely, I could ask "how do you deal with electronic failures that leave the door locked?"
Or when someone without a ticket went in?
If you got on the train, you already have a ticket. Or do you need a separate ticket just to enter the toilet(!?)
Well you wrote this… which makes me think you've never even seen a train in real life.
You should try, before going about designing trains :)
Yes I have been on a train before, and getting to the platform to board it required passing through a ticket gate and security checkpoint.