A negative graduate class experience and maybe some factors in cultural differences
I'm sorry. What happened to you should be very rare, but it does happen sometimes. In US higher education I have seen otherwise good professors embarrass someone by accident (not realizing the effect of their words on the student, or saying something more extreme than they had thought through), and some extremely blunt professors who say this sort of thing on purpose (this group is mixed in whether they are otherwise kind people).

I highly doubt that what the professor did was "justified," but this may depend on the tone they used. In my opinion, intending to embarrass you for this would not be justified. 

As for coping, I suggest you think about whether the professor has done this sort of thing to other people. If so, then other people know what you feel like. If not, then it is unlikely that the professor considered how his words would make you feel. 

It may feel empowering to go to the professor with direct feedback that this was very embarrassing to you. I think that directness might help the professor learn but would even better free you from some of this shame. However, that's expert-level self-confidence and emotional intelligence, and not at all what I did when I was in a similar situation (grad student giving final presentation on my work, and the professor said a few slides in that my approach didn't make sense/wouldn't work; that sort of deflated me and I ended the presentation there--I was the last student to present, the class had already gone over time, and the prof was complaining before my presentation that he needed to leave.). In my case, I never brought it up, there was no direct feedback on the presentation, and I continued going to next term's class with the same prof even when I felt like I was going to cry. I felt embarrassed for a while when I ran into my fellow students from that class. But eventually I figured out my feelings, realized that professor is extremely direct (to put it kindly), and the pain dulled over time.

To prepare for your remaining classes, really be kind to yourself. If you have a friend in this class, try to arrange to come to this class with them so you're not alone at the beginning or end or class. Bring a comforting hot drink with you to class. (Or ice cold drink, depending on weather. :) ) Wear jewelry or put something in your pocket that reminds you of home &amp; loved ones or a meaningful accomplishment. And try to remain engaged with the ideas right in front of you in the class, rather than replaying that class in your mind. If possible, finish a draft of what you need to do for the rest of the class as soon as you can, so you can mentally close the door on this class.

You are almost done with your program! I am sorry that there was this awful experience at the end, but please try to celebrate what you have done!