While I hope you never receive code this bad, we are going to walk through what is needed to turn even this into readable, maintainable, and fully tested code. The best part, the part you aren't going to believe, is that transforming this code is actually safe and fairly easy.
Life sometimes hands you lemons
Getting started
In any code situation like this, the first thing we must do is remove the code in question from the environment where we have no control. In this case, we can't test the code if it is sitting in Program.main. So, let's grab the whole thing and put it into a class named Mastermind. We will have a single function named Play that will run the game. This is considered a safe refactoring, because...